diff --git a/.github/workflows/nightly-validation.yml b/.github/workflows/nightly-validation.yml index ea372ccd8..73c79704b 100644 --- a/.github/workflows/nightly-validation.yml +++ b/.github/workflows/nightly-validation.yml @@ -713,7 +713,7 @@ jobs: # Create a test path with same length as typical setup-z3 usage # This simulates what setup-z3 does: changing to absolute path - TEST_PATH="/Users/runner/hostedtoolcache/z3/latest/x64/z3-4.15.5-x64-osx-15.7.3/bin/libz3.dylib" + TEST_PATH="/Users/runner/hostedtoolcache/z3/latest/x64/z3-test-dir/bin/libz3.dylib" # Try to change the install name - this will fail if headerpad is insufficient install_name_tool -id "$TEST_PATH" -change "$ORIGINAL_NAME" "$TEST_PATH" libz3.dylib @@ -765,7 +765,7 @@ jobs: # Create a test path with same length as typical setup-z3 usage # This simulates what setup-z3 does: changing to absolute path - TEST_PATH="/Users/runner/hostedtoolcache/z3/latest/arm64/z3-4.15.5-arm64-osx-15.7.3/bin/libz3.dylib" + TEST_PATH="/Users/runner/hostedtoolcache/z3/latest/arm64/z3-test-dir/bin/libz3.dylib" # Try to change the install name - this will fail if headerpad is insufficient install_name_tool -id "$TEST_PATH" -change "$ORIGINAL_NAME" "$TEST_PATH" libz3.dylib diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 48cdb953a..163056099 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -2749,7 +2749,7 @@ def mk_config(): CXXFLAGS = '%s -arch arm64' % CXXFLAGS LDFLAGS = '%s -arch arm64' % LDFLAGS SLIBEXTRAFLAGS = '%s -arch arm64' % SLIBEXTRAFLAGS - if IS_OSX and is_ml_enabled(): + if IS_OSX: SLIBFLAGS += ' -Wl,-headerpad_max_install_names' config.write('PREFIX=%s\n' % PREFIX) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2af9a7170..4b78963f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -151,6 +151,11 @@ endif() # so that if those are also shared libraries they are referenced by `libz3.so`. target_link_libraries(libz3 PRIVATE ${Z3_DEPENDENT_LIBS}) +# On macOS, add headerpad for install_name_tool compatibility +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND BUILD_LIBZ3_SHARED) + target_link_options(libz3 PRIVATE "-Wl,-headerpad_max_install_names") +endif() + ################################################################################ # Create include directory with headers for easier developer integration ################################################################################ diff --git a/src/api/java/CMakeLists.txt b/src/api/java/CMakeLists.txt index 862e25962..df0baa334 100644 --- a/src/api/java/CMakeLists.txt +++ b/src/api/java/CMakeLists.txt @@ -50,6 +50,11 @@ target_include_directories(z3java PRIVATE ) # FIXME: Should this library have SONAME and VERSION set? +# On macOS, add headerpad for install_name_tool compatibility +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + target_link_options(z3java PRIVATE "-Wl,-headerpad_max_install_names") +endif() + # This prevents CMake from automatically defining ``z3java_EXPORTS`` set_property(TARGET z3java PROPERTY DEFINE_SYMBOL "") diff --git a/src/api/julia/CMakeLists.txt b/src/api/julia/CMakeLists.txt index 952b33fb5..7b246d6fa 100644 --- a/src/api/julia/CMakeLists.txt +++ b/src/api/julia/CMakeLists.txt @@ -35,6 +35,11 @@ target_include_directories(z3jl PRIVATE "${PROJECT_SOURCE_DIR}/src/api/c++" ) +# On macOS, add headerpad for install_name_tool compatibility +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + target_link_options(z3jl PRIVATE "-Wl,-headerpad_max_install_names") +endif() + option(Z3_INSTALL_JULIA_BINDINGS "Install Julia bindings when invoking install target" ON) if(Z3_INSTALL_JULIA_BINDINGS) install(TARGETS z3jl diff --git a/src/api/ml/CMakeLists.txt b/src/api/ml/CMakeLists.txt index c7de53faa..1007939cb 100644 --- a/src/api/ml/CMakeLists.txt +++ b/src/api/ml/CMakeLists.txt @@ -159,6 +159,8 @@ endif() if( APPLE ) # set(ocaml_rpath "@executable_path/../libz3${so_ext}") + # Add headerpad for install_name_tool compatibility on macOS + list(APPEND c_lib_deps "-Wl,-headerpad_max_install_names") elseif( UNIX ) set(ocaml_rpath "\\$ORIGIN/../libz3${so_ext}") list(APPEND c_lib_deps "-dllpath" ${ocaml_rpath})