diff --git a/.github/actions/helper-build-ldc/action.yml b/.github/actions/helper-build-ldc/action.yml index b5d830e966..badb77ade5 100644 --- a/.github/actions/helper-build-ldc/action.yml +++ b/.github/actions/helper-build-ldc/action.yml @@ -36,8 +36,6 @@ runs: -DLLVM_ROOT_DIR="$PWD/../${{ inputs.llvm_dir }}" \ -DD_COMPILER='${{ inputs.host_dc }}' \ -DLDC_LINK_MANUALLY=OFF \ - ${{ runner.os == 'macOS' && '-DCMAKE_C_COMPILER=/usr/bin/cc' || '' }} \ - ${{ runner.os == 'macOS' && '-DCMAKE_CXX_COMPILER=/usr/bin/c++' || '' }} \ ${{ inputs.specify_install_dir == 'true' && '-DCMAKE_INSTALL_PREFIX="$installDir"' || '' }} \ ${{ inputs.specify_install_dir == 'true' && '-DINCLUDE_INSTALL_DIR="$installDir/import"' || '' }} \ ${{ inputs.cmake_flags }} diff --git a/.github/workflows/supported_llvm_versions.yml b/.github/workflows/supported_llvm_versions.yml index 3f362fd665..1314a6b21e 100644 --- a/.github/workflows/supported_llvm_versions.yml +++ b/.github/workflows/supported_llvm_versions.yml @@ -28,17 +28,17 @@ jobs: os: macos-14 host_dc: ldc-beta llvm_version: 17.0.5 - cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++ + cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib - job_name: macOS 14, LLVM 16, latest LDC beta os: macos-14 host_dc: ldc-beta llvm_version: 16.0.5 - cmake_flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++ + cmake_flags: -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib - job_name: Ubuntu 24.04, LLVM 15, latest DMD beta os: ubuntu-24.04 host_dc: dmd-beta llvm_version: 15 - cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLIB_SUFFIX=64 -DLDC_LINK_MANUALLY=ON + cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLIB_SUFFIX=64 name: ${{ matrix.job_name }} runs-on: ${{ matrix.os }} env: @@ -124,7 +124,6 @@ jobs: cmake -G Ninja . \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ROOT_DIR=${{ runner.os == 'Linux' && format('/usr/lib/llvm-{0}', matrix.llvm_version) || '"$PWD/llvm"' }} \ - -DLDC_LINK_MANUALLY=OFF \ ${{ matrix.cmake_flags }} ninja obj/ldc2.o all ldc2-unittest all-test-runners bin/ldc2 --version diff --git a/CMakeLists.txt b/CMakeLists.txt index 55d1bfa535..44907f2d25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.16.0) if(POLICY CMP0025) cmake_policy(SET CMP0025 NEW) endif() +if(POLICY CMP0132) + # see https://github.com/ldc-developers/ldc/issues/3901 + cmake_policy(SET CMP0132 NEW) +endif() if(${CMAKE_VERSION} VERSION_GREATER "3.26.9") # Prevent implicit dependencies for custom commands, e.g., # `obj/ldc2.o` depending on `lib/libldc.a` with LDC_LINK_MANUALLY=ON. diff --git a/cmake/Modules/BuildDExecutable.cmake b/cmake/Modules/BuildDExecutable.cmake index fe71780b8c..6802e23305 100644 --- a/cmake/Modules/BuildDExecutable.cmake +++ b/cmake/Modules/BuildDExecutable.cmake @@ -100,7 +100,12 @@ function(build_d_executable target_name output_exe d_src_files compiler_args lin # We need to link against the C++ runtime library. if(NOT MSVC AND "${D_COMPILER_ID}" STREQUAL "LDMD" AND NOT "${dflags}" MATCHES "(^|;)-gcc=") - set(translated_linker_args "-gcc=${CMAKE_CXX_COMPILER}" ${translated_linker_args}) + if(CMAKE_VERSION VERSION_LESS "4.0.0" AND APPLE AND "${CMAKE_CXX_COMPILER}" MATCHES "/Developer/.+/usr/bin/c\\+\\+$") + # see https://github.com/ldc-developers/ldc/issues/3901 + set(translated_linker_args "-gcc=/usr/bin/c++" ${translated_linker_args}) + else() + set(translated_linker_args "-gcc=${CMAKE_CXX_COMPILER}" ${translated_linker_args}) + endif() endif() # Use an extra custom target as dependency for the executable in diff --git a/runtime/DRuntimeIntegrationTests.cmake b/runtime/DRuntimeIntegrationTests.cmake index 719e5848a3..1927c0b010 100644 --- a/runtime/DRuntimeIntegrationTests.cmake +++ b/runtime/DRuntimeIntegrationTests.cmake @@ -57,10 +57,19 @@ else() list(REMOVE_ITEM testnames uuid) endif() +set(musl "") if(TARGET_SYSTEM MATCHES "musl") set(musl "IS_MUSL=1") endif() +set(cc "CC=${CMAKE_C_COMPILER}") +set(cxx "CXX=${CMAKE_CXX_COMPILER}") +if(CMAKE_VERSION VERSION_LESS "4.0.0" AND CMAKE_HOST_APPLE AND "${TARGET_SYSTEM}" MATCHES "APPLE") + # see https://github.com/ldc-developers/ldc/issues/3901 + set(cc "") + set(cxx "") +endif() + foreach(name ${testnames}) foreach(build debug release) set(druntime_path_build ${druntime_path}) @@ -78,10 +87,9 @@ foreach(name ${testnames}) add_test(NAME ${fullname} COMMAND ${GNU_MAKE_BIN} -C ${PROJECT_SOURCE_DIR}/druntime/test/${name} ROOT=${outdir} DMD=${LDMD_EXE_FULL} BUILD=${build} SHARED=1 - CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} DRUNTIME=${druntime_path_build} DRUNTIMESO=${shared_druntime_path_build} - CFLAGS_BASE=${cflags_base} DFLAGS_BASE=${dflags_base} ${linkdl} - IN_LDC=1 ${musl} + ${cc} ${cxx} CFLAGS_BASE=${cflags_base} DFLAGS_BASE=${dflags_base} ${linkdl} + IN_LDC=1 ${musl} ) set_tests_properties(${fullname} PROPERTIES DEPENDS clean-${fullname}) endforeach()