Skip to content

Tweaks for building with macOS 26#11605

Merged
mitchute merged 18 commits into
developfrom
xcode-generated-builds
Jun 5, 2026
Merged

Tweaks for building with macOS 26#11605
mitchute merged 18 commits into
developfrom
xcode-generated-builds

Conversation

@mitchute

@mitchute mitchute commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Pull request overview

  • A collection of tweaks needed to get EnergyPlus building on macOS 26 for Xcode- and Unix-generated makefiles.

Description of the purpose of this PR

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies
  • If adding/removing any output files (e.g., eplustbl.*)
    • Update ..\scripts\Epl-run.bat
    • Update ..\scripts\RunEPlus.bat
    • Update ..\src\EPLaunch\ MainModule.bas, epl-ui.frm, and epl.vbp (VersionComments)
    • Update ...github\workflows\energyplus.py

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@mitchute mitchute requested a review from RKStrand May 27, 2026 00:25
@mitchute mitchute added the DoNotPublish Includes changes that shouldn't be reported in the changelog label May 27, 2026
@mitchute mitchute changed the title Suppress Implicit 64-to-32 bit Conversion Errors for Xcode Generated Builds Compiler Tweaks for macOS 26 May 27, 2026
@mitchute mitchute changed the title Compiler Tweaks for macOS 26 Tweaks for building with macOS 26 May 27, 2026

@jmarrec jmarrec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get why we have XCode specific stuff but maybe it's really needed?

I pushed a branch with only 2 changes that allows me to build on Apple Clang 21 (macOS 26.5 fully up to date)

https://github.com/NatLabRockies/EnergyPlus/compare/build_apple-clang-21?expand=1

Comment thread cmake/CompilerFlags.cmake Outdated
Comment on lines +131 to +133
if(CMAKE_GENERATOR STREQUAL "Xcode")
target_compile_options(project_warnings INTERFACE -Wno-shorten-64-to-32)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tweaks locally to build on apple-clang 21, and I haven't needed to add this?

Also, is this really Xcode generator specific?

(I would have expected CMAKE_CXX_COMPILER_ID MATCHES "Clang")

Comment thread idd/CMakeLists.txt Outdated

add_executable(generate_embeddable_epJSON_schema embedded/generate_embeddable_epJSON_schema.cpp)
target_link_libraries(generate_embeddable_epJSON_schema PRIVATE project_options project_fp_options project_warnings fmt::fmt)
target_link_libraries(generate_embeddable_epJSON_schema PRIVATE project_options project_fp_options project_warnings fmt::fmt nlohmann_json)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't needed that either

Comment thread third_party/CLI/CLI11.hpp Outdated
Comment on lines +161 to +164
#ifndef CLI11_HAS_CODECVT
#if defined(__APPLE__) && defined(__clang__)
#define CLI11_HAS_CODECVT 0
#elif defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're doing. This is better than my own

    target_compile_options(project_warnings INTERFACE -Wno-deprecated-declarations) # wstring_convert deprecated in newer libc++

I wonder if it's better to have it inline in CLI11.hpp or if it should be in CMake via target_compile_definitions(xxx PRIVATE CLI11_HAS_CODECVT=0) (for targets energyplus and convertInputFormat). I guess inline is fine.

@mitchute

mitchute commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@RKStrand

RKStrand commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@mitchute @jmarrec Ok, I just tried this. Pulled it down, ran configure and generate on CMake, cleaned the build folder in Xcode, and then tried to build. It was not successful. Here are the error messages:

image

@mitchute

mitchute commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

OK. I also see this with Xcode and Apple Clang 17. Can you try a Unix makefile build with CLion?

@RKStrand

RKStrand commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

I was just able to successfully build using CLion--both energyplus and energyplus_tests. Was able to successfully run 1ZoneUncontrolled.idf using this energyplus build and the test suite completed 1260 test successfully. Not sure why it didn't do every unit test but at least it successfully completed what it did.

I'd love to get Xcode running again, but at least having CLion up and running is super helpful.

@RKStrand

RKStrand commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

For the record, in case it helps, I'm running a Nov 2023 MacBook Pro 16-inch, with the Apple M3 Max chip, 128 GB of memory, macOS Tahoe26.5, and Xcode Version 26.5 (17F42).

@mitchute

mitchute commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Was able to successfully run 1ZoneUncontrolled.idf using this energyplus build and the test suite completed 1260 test successfully. Not sure why it didn't do every unit test but at least it successfully completed what it did.

@RKStrand can you post anything regarding what caused the failure in completing all the tests?

@RKStrand

RKStrand commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

I just tried this in debug and here is a place that it seems to have a problem:

image

@mitchute

mitchute commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @RKStrand. I saw that as well.

@mitchute

mitchute commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

@RKStrand

RKStrand commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@mitchute Ok, here is what I got on my machine:

Big Picture for "msm" branch: Xcode builds and runs successfully, CLion encounters an error building energyplus_tests (details below)

Xcode:
energyplus--builds successfully (two warnings in epexpat related to xmltok_ but that didn't prevent the build) and ran 1ZoneUncontrolled.idf without issue
energyplus_tests--builds successfully (same warnings) and runs all tests (2229) successfully without any issues

CLion:
energyplus--buildings successfully and ran 1ZoneUncontrolled.idf without issue
energyplus_tests--build error as shown here...

.../third_party/gtest/googletest/include/gtest/gtest-printers.h:478:35: error: implicit conversion from 'char8_t' to 'char32_t' may change the meaning of the represented code unit [-Werror,-Wcharacter-conversion]
478 | PrintTo(ImplicitCast_<char32_t>(c), os);

It points to the (c) in that line as the issue.

@mitchute

mitchute commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

Right... I missed that change here. I'll push a patch soon.

@mitchute

mitchute commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

@RKStrand give it another shot now.

@RKStrand

RKStrand commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@mitchute Ok, after that, now I can say: Xcode--same as before (everything good).

CLion--energyplus still builds and runs. energyplus_tests builds now. What is a bit weird is that when I run it, it only does 1260 tests and then at some point, I get the following pop-up window (see left of image below).

image

If I click on ignore, it just stops right there. If I click on "Reopen", it launches a terminal window and tries to run energyplus_tests from the terminal. But that doesn't finish either because as you can see from the right side of the image, it seems to crash in a Solar Shading test.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 7601b2a

Regression Summary
  • ERR: 1

@jmarrec

jmarrec commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

I just tried this in debug and here is a place that it seems to have a problem:

Penumbra tests on arm64 debug have always been problematic for what it's worth.

@mitchute mitchute left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this passes the other builds, I'm done. @jmarrec the commit history on this is a disaster. Do we do a squash merge, or port it to a fresh branch and then just merge that?

Comment thread cmake/ProjectMacros.cmake
Comment on lines +86 to +90
if(APPLE AND CMAKE_GENERATOR STREQUAL "Xcode")
set(_gtest_discovery_mode PRE_TEST)
else()
set(_gtest_discovery_mode POST_BUILD)
endif()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, this was due to something related to Xcode and code signing, which we are not doing during development builds.

Comment thread idd/CMakeLists.txt

add_executable(generate_embeddable_epJSON_schema embedded/generate_embeddable_epJSON_schema.cpp)
target_link_libraries(generate_embeddable_epJSON_schema PRIVATE project_options project_fp_options project_warnings fmt::fmt)
target_compile_options(generate_embeddable_epJSON_schema PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wno-shorten-64-to-32>)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns this into a warning. I think this should just apply to AppleClang and I thought I changed it to that everywhere else, but now I see that I missed this one. I'll probably just leave it.


target_include_directories(airflownetworklib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(airflownetworklib PUBLIC btwxt fmt::fmt)
target_link_libraries(airflownetworklib PUBLIC btwxt fmt::fmt PRIVATE nlohmann_json)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My machine was complaining about the nlohman json.hpp #include <doj/alphanum.hpp>. This fixed it.

}
# else
constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg<char> {
constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg<char> {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were a couple random things like this that it didn't like.

Comment on lines +141 to +142
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wno-character-conversion>
$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wno-deprecated-declarations>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies these based on what's available in each compiler.

Comment thread CMakeLists.txt
Comment on lines +95 to +98
if(APPLE AND CMAKE_GENERATOR STREQUAL "Xcode" AND OPENGL_FOUND)
set(OPENGL_FOUND FALSE)
message(STATUS "Disabling OpenGL for Xcode-generated builds to avoid Cocoa window creation during build/test execution")
endif()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Penumbra want to create some windows behind the scenes when OpenGL is enabled, which it is by default. We could probably have worked through that, but since this isn't likely to be used by many of our developers, I figured we'd just turn it off when running from an Xcode generated build.

@mitchute

mitchute commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @RKStrand for bearing with me to test this, and thanks @jmarrec for your review and contributions. Merging.

@mitchute mitchute merged commit df920a0 into develop Jun 5, 2026
11 checks passed
@mitchute mitchute deleted the xcode-generated-builds branch June 5, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DoNotPublish Includes changes that shouldn't be reported in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants