Skip to content

Modify cmake build to build on MacOS #6344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

markrtuttle
Copy link
Collaborator

This pull request modifies the cmake build on MacOS to follow the instructions used in the homebrew cbmc formula for building cbmc on MacOS. This should make it easy to build cbmc on MacOS everywhere with just cmake -S . -B build -GNinja.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@markrtuttle markrtuttle requested a review from a team as a code owner September 15, 2021 22:35
@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

Merging #6344 (adb3a0a) into develop (9d774a7) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6344      +/-   ##
===========================================
- Coverage    75.90%   75.90%   -0.01%     
===========================================
  Files         1515     1515              
  Lines       164002   164004       +2     
===========================================
+ Hits        124482   124483       +1     
- Misses       39520    39521       +1     
Impacted Files Coverage Δ
src/goto-analyzer/unreachable_instructions.cpp 90.95% <100.00%> (-0.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e4b5c6...adb3a0a. Read the comment docs.

Copy link
Contributor

@thomasspriggs thomasspriggs left a comment

Choose a reason for hiding this comment

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

I am not sure that forcing these settings on certain platforms, rather than fixing the build environment is the right approach. @NlightNFotis what do you think?

CMakeLists.txt Outdated
# Don't build jbmc on MacOS running on ARM
# See https://github.com/Homebrew/homebrew-core/blob/master/Formula/cbmc.rb
# See https://github.com/diffblue/cbmc/issues/6343
execute_process(COMMAND uname -p
Copy link
Contributor

Choose a reason for hiding this comment

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

This I'm less happy about. Fundamentally, it looks like the issue is nothing to do with macos and/or M1 architecture. Its entirely down to Java version. It just happens that at this moment in time, brew will install a JVM 17 preview release on M1 macs (but still installs a JVM16 on x86 macs). I strongly suspect that as soon as more JVM17's are installed on other platforms (and OpenJDK 17 has just been officially released: https://mail.openjdk.java.net/pipermail/jdk-dev/2021-September/006037.html) this will bite other platforms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

Hi Mark, good stuff 👍🏻

I think the second change is not really needed. If that's removed it's good to go from me 👍🏻

@markrtuttle
Copy link
Collaborator Author

Instead of trying to force -DWITH_JBMC=OFF on Apple M1, I now suggest (for the inexperienced user) to try building with -DWITH_JBMC=OFF if jbmc fails to build on MacOS.

Can we finish off the Java 16/17 issue quickly so we can delete this completely?

CMakeLists.txt Outdated
@@ -231,6 +240,10 @@ cprover_default_properties(
xml)

option(WITH_JBMC "Build the JBMC Java front-end" ON)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
# See https://github.com/diffblue/cbmc/issues/6343
message(STATUS "Use -DWITH_JBMC=OFF if jbmc fails to build on MacOS")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think (until we can fix the models library) this would be better as a check against the Java version, and then print a warning message and automatically set WITH_JBMC=OFF. Ultimately this is not about Darwin or any particular OS/architecture - its purely a Java version/API change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Build with CMAKE_C_COMPILER=/usr/bin/clang when building on MacOS.
Build with -DWITH_JBMC=OFF when building with  Java version > 16.
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@NlightNFotis
Copy link
Contributor

Please do not merge this yet!

We have fixed the issues in the Models Library, and we are now unblocked in terms of the Homebrew PR. I am looking into making the homebrew PR based on Java 17 (I can build with Java 17 locally no problem after the Models Library fix), and after this, then the only change required here is the default setup of the compiler to the /usr/bin/clang.

option(WITH_JBMC "Build the JBMC Java front-end" ON)
if(NOT JAVA_VERSION VERSION_LESS 17)
Copy link
Contributor

Choose a reason for hiding this comment

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

When https://github.com/Homebrew/homebrew-core/pull/85720/files gets merged to homebrew, cbmc (and jbmc by extension) will build cleanly with openJDK (version 17).

If you could drop the java version checks here (or at least, not deactivate jbmc building if java --version >= 17), then that would be great.

@markrtuttle
Copy link
Collaborator Author

Closing in favor of #6359. The JDK 17 issues dealt with here are being fixed in another pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants