From dad1df573d71e46609f9ba2d8f16d93f09c9d2a7 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 10:51:58 +0300 Subject: [PATCH 01/15] runtime/CMakeLists.txt: Depend only on the full path to the ldc binary For custom commands that require a built ldc2 specify only an absolute path to compiler binary, not the target name. This is because cmake handles file paths and target dependencies differently. In the case of a target dependency the dependency doesn't actually apply to the `add_custom_command`, it only affects future targets. As an example, we want to built libruntime.a from a D file foo.d. What we need to describe is: 1. compile foo.o from foo.d (depends on LDC) 2. archive libruntime.a from foo.o If we use ${LDC_EXE} as a dependency (only the target name) cmake would generate: 1. compile foo.o from foo.d 2. archive libruntime.a from foo.o (depends on LDC) Using an absolute path for the LDC dependency does what we want it to do. Signed-off-by: Andrei Horodniceanu --- runtime/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index fcbed7e6c6..1b43b7b64b 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -337,7 +337,7 @@ if(LDC_EXE) "$<$:${MULTILIB_DIR}>" ${conf_path}.in ${conf_path} - DEPENDS ${LDC_EXE} ${LDC_EXE_FULL} + DEPENDS ${LDC_EXE_FULL} ) add_custom_command(OUTPUT ${install_conf_path} VERBATIM COMMAND ${PROJECT_PARENT_DIR}/tools/add-multilib-section.sh @@ -347,7 +347,7 @@ if(LDC_EXE) "$<$:${MULTILIB_INSTALL_DIR}>" ${install_conf_path}.in ${install_conf_path} - DEPENDS ${LDC_EXE} ${LDC_EXE_FULL} + DEPENDS ${LDC_EXE_FULL} ) add_custom_target(add-multilib-section ALL DEPENDS ${conf_path} ${install_conf_path} @@ -437,7 +437,9 @@ macro(dc src_files src_basedir d_flags output_basedir emit_bc all_at_once single list(APPEND dc_flags -flto=thin --output-bc) endif() - set(dc_deps ${LDC_EXE} ${LDC_EXE_FULL} ${GCCBUILTINS}) + # dc_deps can only contain paths, otherwise cmake will ignore the dependency. + # See: https://github.com/ldc-developers/ldc/pull/4743#issuecomment-2323156173 + set(dc_deps ${LDC_EXE_FULL} ${GCCBUILTINS}) if(TARGET add-multilib-section) # Make sure the config files are available before invoking LDC. set(dc_deps ${dc_deps} add-multilib-section) From ee381a32d37c38997c40739c7b8a3045fcaa6299 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 10:53:18 +0300 Subject: [PATCH 02/15] runtime/CMakeLists.txt: Call cmake_minimum_required before project() Signed-off-by: Andrei Horodniceanu --- runtime/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 1b43b7b64b..1349294894 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,6 +1,5 @@ -project(runtime C ASM) - cmake_minimum_required(VERSION 3.4.3) +project(runtime C ASM) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) From dcf855579b746b9f2b6a2700395ff05881dfd97e Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 11:03:57 +0300 Subject: [PATCH 03/15] runtime/CMakeLists.txt: add call to enable_testing() Signed-off-by: Andrei Horodniceanu --- runtime/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 1349294894..2d2d7e8130 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -906,6 +906,7 @@ install(FILES ${GCCBUILTINS} DESTINATION ${INCLUDE_INSTALL_DIR}/ldc) # # Test targets. # +enable_testing() # Build the "test runner" executables containing the druntime and Phobos unit # tests. They are invoked with the modules to test later. From 0dcf778931d2ac22b4886af686cc1bef0ddb9398 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 29 Aug 2024 11:46:31 +0300 Subject: [PATCH 04/15] runtime/DRuntimeIntegrationTests.cmake: Pass D_EXTRA_FLAGS to ldmd D_EXTRA_FLAGS is the intended way to pass flags like -m32 to ldc so make sure that its value is respected during the druntime tests. Signed-off-by: Andrei Horodniceanu --- runtime/DRuntimeIntegrationTests.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/DRuntimeIntegrationTests.cmake b/runtime/DRuntimeIntegrationTests.cmake index a10b560759..782ae9358a 100644 --- a/runtime/DRuntimeIntegrationTests.cmake +++ b/runtime/DRuntimeIntegrationTests.cmake @@ -56,6 +56,8 @@ else() list(REMOVE_ITEM testnames uuid) endif() +string(REPLACE ";" " " LDMD_CMD "${LDMD_EXE_FULL} ${D_EXTRA_FLAGS}") + foreach(name ${testnames}) foreach(build debug release) set(druntime_path_build ${druntime_path}) @@ -72,7 +74,7 @@ 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} + ROOT=${outdir} DMD=${LDMD_CMD} BUILD=${build} DRUNTIME=${druntime_path_build} DRUNTIMESO=${shared_druntime_path_build} SHARED=1 ${cflags_base} ${linkdl} ) From 7f313035f87a5f364e868e98b5cc85b2c902b8a4 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 12 Sep 2024 19:01:16 +0200 Subject: [PATCH 05/15] [druntime: Pass D_EXTRA_FLAGS and RT_CFLAGS in {C,D}FLAGS_BASE for make-based integration tests] --- runtime/DRuntimeIntegrationTests.cmake | 15 +++++++++------ runtime/druntime/test/common.mak | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/runtime/DRuntimeIntegrationTests.cmake b/runtime/DRuntimeIntegrationTests.cmake index 782ae9358a..4b83eea932 100644 --- a/runtime/DRuntimeIntegrationTests.cmake +++ b/runtime/DRuntimeIntegrationTests.cmake @@ -34,8 +34,13 @@ else() endif() endif() -if(NOT "${TARGET_SYSTEM}" MATCHES "MSVC") - set(cflags_base "CFLAGS_BASE=-Wall -Wl,-rpath,${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}") +string(REPLACE ";" " " dflags_base "${D_EXTRA_FLAGS}") + +string(REPLACE ";" " " cflags_base "${RT_CFLAGS}") +if("${TARGET_SYSTEM}" MATCHES "MSVC") + set(cflags_base "${cflags_base} /Wall") +else() + set(cflags_base "${cflags_base} -Wall -Wl,-rpath,${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}") endif() set(linkdl "") @@ -56,8 +61,6 @@ else() list(REMOVE_ITEM testnames uuid) endif() -string(REPLACE ";" " " LDMD_CMD "${LDMD_EXE_FULL} ${D_EXTRA_FLAGS}") - foreach(name ${testnames}) foreach(build debug release) set(druntime_path_build ${druntime_path}) @@ -74,9 +77,9 @@ foreach(name ${testnames}) ) add_test(NAME ${fullname} COMMAND ${GNU_MAKE_BIN} -C ${PROJECT_SOURCE_DIR}/druntime/test/${name} - ROOT=${outdir} DMD=${LDMD_CMD} BUILD=${build} + ROOT=${outdir} DMD=${LDMD_EXE_FULL} BUILD=${build} SHARED=1 DRUNTIME=${druntime_path_build} DRUNTIMESO=${shared_druntime_path_build} - SHARED=1 ${cflags_base} ${linkdl} + CFLAGS_BASE=${cflags_base} DFLAGS_BASE=${dflags_base} ${linkdl} ) set_tests_properties(${fullname} PROPERTIES DEPENDS clean-${fullname}) endforeach() diff --git a/runtime/druntime/test/common.mak b/runtime/druntime/test/common.mak index 10e3f949da..ed7e53b801 100644 --- a/runtime/druntime/test/common.mak +++ b/runtime/druntime/test/common.mak @@ -37,8 +37,8 @@ ifeq (,$(findstring ldmd2,$(DMD))) CFLAGS_BASE+=--target=x86_64-darwin-apple # ARM cpu is not supported by dmd endif endif -# LDC: use `-defaultlib=druntime-ldc [-link-defaultlib-shared]` instead of `-defaultlib= -L$(DRUNTIME[_IMPLIB])` -DFLAGS:=$(MODEL_FLAG) $(PIC) -w -I../../src -I../../import -I$(SRC) -defaultlib=$(if $(findstring ldmd2,$(DMD)),druntime-ldc,) -preview=dip1000 $(if $(findstring $(OS),windows),,-L-lpthread -L-lm $(LINKDL)) +# LDC: include optional DFLAGS_BASE and use `-defaultlib=druntime-ldc [-link-defaultlib-shared]` instead of `-defaultlib= -L$(DRUNTIME[_IMPLIB])` +DFLAGS:=$(MODEL_FLAG) $(PIC) $(DFLAGS_BASE) -w -I../../src -I../../import -I$(SRC) -defaultlib=$(if $(findstring ldmd2,$(DMD)),druntime-ldc,) -preview=dip1000 $(if $(findstring $(OS),windows),,-L-lpthread -L-lm $(LINKDL)) # LINK_SHARED may be set by importing makefile ifeq (,$(findstring ldmd2,$(DMD))) DFLAGS+=$(if $(LINK_SHARED),-L$(DRUNTIME_IMPLIB) $(if $(findstring $(OS),windows),-dllimport=all),-L$(DRUNTIME)) From 48b38b278c801ecdd4529c5552b846735d122f63 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 14:58:20 +0200 Subject: [PATCH 06/15] [druntime: Pass CMAKE_C[XX]_COMPILER as CC/CXX for make-based integration tests] To propagate the C[++] compilers at CMake configure-time to test-time. --- runtime/CMakeLists.txt | 2 +- runtime/DRuntimeIntegrationTests.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 2d2d7e8130..3b08893d34 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.4.3) -project(runtime C ASM) +project(runtime C ASM CXX) # CXX for integration tests only set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/runtime/DRuntimeIntegrationTests.cmake b/runtime/DRuntimeIntegrationTests.cmake index 4b83eea932..45ff4e050b 100644 --- a/runtime/DRuntimeIntegrationTests.cmake +++ b/runtime/DRuntimeIntegrationTests.cmake @@ -78,6 +78,7 @@ 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} ) From 71a6f26c8adde39a6853baf0df5643f926524a06 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 15:09:49 +0200 Subject: [PATCH 07/15] [ldc-build-runtime: Define LDMD_EXE_FULL for druntime integration tests] --- runtime/ldc-build-runtime.d.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/ldc-build-runtime.d.in b/runtime/ldc-build-runtime.d.in index 226c77e890..fe7d3a47d6 100644 --- a/runtime/ldc-build-runtime.d.in +++ b/runtime/ldc-build-runtime.d.in @@ -150,9 +150,12 @@ void prepareLdcSource() { void runCMake() { const wd = WorkingDirScope(config.buildDir); + const ldmdExecutable = buildPath(config.ldcExecutable.dirName, "ldmd2" ~ exeSuffix); + string[] args = [ "cmake", "-DLDC_EXE_FULL=" ~ config.ldcExecutable, + "-DLDMD_EXE_FULL=" ~ ldmdExecutable, "-DDMDFE_MINOR_VERSION=@DMDFE_MINOR_VERSION@", "-DDMDFE_PATCH_VERSION=@DMDFE_PATCH_VERSION@", ]; From 074c388744d62b023c299174e2261f9a37f2e9bc Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 17:38:00 +0200 Subject: [PATCH 08/15] [druntime: Work around clang-cl bug in test/shared/Makefile] --- runtime/druntime/test/shared/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/druntime/test/shared/Makefile b/runtime/druntime/test/shared/Makefile index 0ba78e6ff9..43f977b690 100644 --- a/runtime/druntime/test/shared/Makefile +++ b/runtime/druntime/test/shared/Makefile @@ -131,24 +131,24 @@ $(ROOT)/dynamiccast$(DOTDLL): $(SRC)/dynamiccast.d $(if $(LINK_SHARED),$(DRUNTI ifeq (windows,$(OS)) CC:=cl CC_OUTFLAG:=/Fe - # we additionally specify the .obj output path (/Fo) to prevent collisions - CC_EXTRAS:= + # additionally specify the .obj output directory to prevent collisions + CC_EXTRAS:=/Fo$(ROOT)/ else CC_OUTFLAG:=-o CC_EXTRAS:=$(LDL) -pthread endif $(ROOT)/linkD$(DOTEXE): $(SRC)/linkD.c $(ROOT)/lib$(DOTDLL) $(DRUNTIMESO) - $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $(if $(findstring $(OS),windows),/Fo$@.obj,) $< $(ROOT)/lib$(DOTIMPLIB) $(CC_EXTRAS) + $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $< $(ROOT)/lib$(DOTIMPLIB) $(CC_EXTRAS) $(ROOT)/linkDR$(DOTEXE): $(SRC)/linkDR.c $(ROOT)/lib$(DOTDLL) $(DRUNTIMESO) - $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $(if $(findstring $(OS),windows),/Fo$@.obj,) $< $(DRUNTIME_IMPLIB) $(CC_EXTRAS) + $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $< $(DRUNTIME_IMPLIB) $(CC_EXTRAS) $(ROOT)/loadDR$(DOTEXE): $(SRC)/loadDR.c $(ROOT)/lib$(DOTDLL) $(DRUNTIMESO) - $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $(if $(findstring $(OS),windows),/Fo$@.obj,) $< $(CC_EXTRAS) + $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $< $(CC_EXTRAS) $(ROOT)/host$(DOTEXE): $(SRC)/host.c $(ROOT)/plugin1$(DOTDLL) $(ROOT)/plugin2$(DOTDLL) - $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $(if $(findstring $(OS),windows),/Fo$@.obj,) $< $(CC_EXTRAS) + $(QUIET)$(CC) $(CFLAGS) $(CC_OUTFLAG)$@ $< $(CC_EXTRAS) $(ROOT)/liblinkdep$(DOTDLL): $(ROOT)/lib$(DOTDLL) $(ROOT)/liblinkdep$(DOTDLL): DFLAGS+=-L$(ROOT)/lib$(DOTIMPLIB) From 03abcf8507fe64fd31fcc3b0a41fb42141f7266f Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 18:03:56 +0200 Subject: [PATCH 09/15] CI: Try a different workaround for Apple issue #3901 --- .github/workflows/main.yml | 15 +++++++++++---- .github/workflows/supported_llvm_versions.yml | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2e4a495c31..99a33ba54f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,15 +39,19 @@ jobs: - job_name: macOS x86_64 os: macos-12 arch: x86_64 + # wrt. CMAKE_C[XX]_COMPILER: https://github.com/ldc-developers/ldc/issues/3901 bootstrap_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ + -DCMAKE_C_COMPILER=/usr/bin/cc + -DCMAKE_CXX_COMPILER=/usr/bin/c++ # https://github.com/ldc-developers/ldc/issues/4462: # When using LTO, we need to explicitly export ~all symbols for plugin support via `ld64 -exported_symbol '__*'`. # Additionally `-w` to suppress resulting linker warnings. extra_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DD_COMPILER_FLAGS="-gcc=/usr/bin/c++ -O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w" + -DCMAKE_C_COMPILER=/usr/bin/cc + -DCMAKE_CXX_COMPILER=/usr/bin/c++ + -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w" -DEXTRA_CXXFLAGS=-flto=full with_pgo: true @@ -56,10 +60,13 @@ jobs: arch: arm64 bootstrap_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ + -DCMAKE_C_COMPILER=/usr/bin/cc + -DCMAKE_CXX_COMPILER=/usr/bin/c++ extra_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DD_COMPILER_FLAGS="-gcc=/usr/bin/c++ -O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w" + -DCMAKE_C_COMPILER=/usr/bin/cc + -DCMAKE_CXX_COMPILER=/usr/bin/c++ + -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w" -DEXTRA_CXXFLAGS=-flto=full with_pgo: true diff --git a/.github/workflows/supported_llvm_versions.yml b/.github/workflows/supported_llvm_versions.yml index 4e884dc6dc..a6d6fa7b06 100644 --- a/.github/workflows/supported_llvm_versions.yml +++ b/.github/workflows/supported_llvm_versions.yml @@ -25,12 +25,12 @@ jobs: os: macos-14 host_dc: ldc-beta llvm_version: 17.0.5 - cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib + 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++ - 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 -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib + 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++ - job_name: Ubuntu 20.04, LLVM 15, latest DMD beta os: ubuntu-20.04 host_dc: dmd-beta From 29a1eb5bea950f18372fadebef898c6e8e4bcbe2 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 18:16:13 +0200 Subject: [PATCH 10/15] [tiny refactoring wrt. CXX language dependency for runtime build] --- runtime/CMakeLists.txt | 2 +- runtime/DRuntimeIntegrationTests.cmake | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 3b08893d34..2d2d7e8130 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.4.3) -project(runtime C ASM CXX) # CXX for integration tests only +project(runtime C ASM) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/runtime/DRuntimeIntegrationTests.cmake b/runtime/DRuntimeIntegrationTests.cmake index 45ff4e050b..fbb38e9840 100644 --- a/runtime/DRuntimeIntegrationTests.cmake +++ b/runtime/DRuntimeIntegrationTests.cmake @@ -1,3 +1,5 @@ +enable_language(CXX) # for CMAKE_CXX_COMPILER + # Try to find GNU make, use specific version first (BSD) and fall back to default 'make' (Linux) find_program(GNU_MAKE_BIN NAMES gmake gnumake make) if(NOT GNU_MAKE_BIN) From 140cb6d9d59f218d74f82f8650372c85a0d7934a Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 19:55:41 +0200 Subject: [PATCH 11/15] [fix Win32 CI via explicit -m32 for clang-cl used for druntime integration tests] --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99a33ba54f..80f9679ad7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,8 +84,10 @@ jobs: os: windows-2022 arch: x86 bootstrap_cmake_flags: -DBUILD_LTO_LIBS=ON + # `RT_CFLAGS=-m32` needed to make 64-bit clang-cl output 32-bit code for druntime integration tests extra_cmake_flags: >- -DBUILD_LTO_LIBS=ON + -DRT_CFLAGS=-m32 # Undefined symbol errors with FullLTO; ThinLTO used to work, but apparently miscompiles a lexer.d:138 assertion since v1.33. # "-DD_COMPILER_FLAGS=-O -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" # -DEXTRA_CXXFLAGS=-flto=thin From 36d6f581c30b6e6221dc79cb1608d09b545afe7c Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 13 Sep 2024 20:50:47 +0200 Subject: [PATCH 12/15] [druntime: Streamline Windows part of stdcpp integration test] --- runtime/druntime/test/stdcpp/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/druntime/test/stdcpp/Makefile b/runtime/druntime/test/stdcpp/Makefile index 1fc6d23567..3d55bf54a2 100644 --- a/runtime/druntime/test/stdcpp/Makefile +++ b/runtime/druntime/test/stdcpp/Makefile @@ -4,7 +4,7 @@ include ../common.mak ifeq (windows,$(OS)) -CC:=cl +CXX:=cl EXTRA_CXXFLAGS:=/nologo /EHsc EXTRA_DFLAGS:= @@ -23,19 +23,19 @@ $(ROOT)/%: $(SRC)/%.cpp $(SRC)/%_test.d @echo Testing $* @mkdir -p $(dir $@) - $(QUIET)$(CC) /MT $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< + $(QUIET)$(CXX) /MT $(CXXFLAGS_BASE) $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< $(QUIET)$(DMD) -mscrtlib=libcmt $(DFLAGS) $(EXTRA_DFLAGS) -main -unittest -version=CoreUnittest -version=_MSC_VER_$(MSC_VER) -of$@$(DOTEXE) $@_cpp$(DOTOBJ) $(SRC)/$*_test.d $(QUIET)$(TIMELIMIT)$@ $(RUN_ARGS) - $(QUIET)$(CC) /MD $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< + $(QUIET)$(CXX) /MD $(CXXFLAGS_BASE) $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< $(QUIET)$(DMD) -mscrtlib=msvcrt $(DFLAGS) $(EXTRA_DFLAGS) -main -unittest -version=CoreUnittest -version=_MSC_VER_$(MSC_VER) -of$@$(DOTEXE) $@_cpp$(DOTOBJ) $(SRC)/$*_test.d $(QUIET)$(TIMELIMIT)$@ $(RUN_ARGS) - $(QUIET)$(CC) /MTd $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< + $(QUIET)$(CXX) /MTd $(CXXFLAGS_BASE) $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< $(QUIET)$(DMD) -mscrtlib=libcmtd $(DFLAGS) $(EXTRA_DFLAGS) -main -unittest -version=CoreUnittest -version=_MSC_VER_$(MSC_VER) -of$@$(DOTEXE) $@_cpp$(DOTOBJ) $(SRC)/$*_test.d $(QUIET)$(TIMELIMIT)$@ $(RUN_ARGS) - $(QUIET)$(CC) /MDd $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< + $(QUIET)$(CXX) /MDd $(CXXFLAGS_BASE) $(EXTRA_CXXFLAGS) -c /Fo$@_cpp$(DOTOBJ) $< $(QUIET)$(DMD) -mscrtlib=msvcrtd $(DFLAGS) $(EXTRA_DFLAGS) -main -unittest -version=CoreUnittest -version=_MSC_VER_$(MSC_VER) -of$@$(DOTEXE) $@_cpp$(DOTOBJ) $(SRC)/$*_test.d $(QUIET)$(TIMELIMIT)$@ $(RUN_ARGS) From cd9f493cf326675839dc39ef2fb0efbcdd19986e Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 20 Sep 2024 11:18:21 +0100 Subject: [PATCH 13/15] [CI: Make workaround for #3901 a bit less ugly] --- .github/actions/helper-build-ldc/action.yml | 3 +++ .github/workflows/main.yml | 9 --------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/actions/helper-build-ldc/action.yml b/.github/actions/helper-build-ldc/action.yml index 3fafd106f0..b5d830e966 100644 --- a/.github/actions/helper-build-ldc/action.yml +++ b/.github/actions/helper-build-ldc/action.yml @@ -30,11 +30,14 @@ runs: installDir="$PWD/install" mkdir '${{ inputs.build_dir }}' cd '${{ inputs.build_dir }}' + # wrt. CMAKE_C[XX]_COMPILER for Apple: https://github.com/ldc-developers/ldc/issues/3901 cmake -G Ninja ../ldc \ -DCMAKE_BUILD_TYPE=Release \ -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/main.yml b/.github/workflows/main.yml index 80f9679ad7..0dcb8fe504 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,18 +39,13 @@ jobs: - job_name: macOS x86_64 os: macos-12 arch: x86_64 - # wrt. CMAKE_C[XX]_COMPILER: https://github.com/ldc-developers/ldc/issues/3901 bootstrap_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DCMAKE_C_COMPILER=/usr/bin/cc - -DCMAKE_CXX_COMPILER=/usr/bin/c++ # https://github.com/ldc-developers/ldc/issues/4462: # When using LTO, we need to explicitly export ~all symbols for plugin support via `ld64 -exported_symbol '__*'`. # Additionally `-w` to suppress resulting linker warnings. extra_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DCMAKE_C_COMPILER=/usr/bin/cc - -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w" -DEXTRA_CXXFLAGS=-flto=full with_pgo: true @@ -60,12 +55,8 @@ jobs: arch: arm64 bootstrap_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DCMAKE_C_COMPILER=/usr/bin/cc - -DCMAKE_CXX_COMPILER=/usr/bin/c++ extra_cmake_flags: >- -DBUILD_LTO_LIBS=ON - -DCMAKE_C_COMPILER=/usr/bin/cc - -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w" -DEXTRA_CXXFLAGS=-flto=full with_pgo: true From 99883ac46b4fdb4a305b0f471fadb176fba7a297 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 20 Sep 2024 11:21:51 +0100 Subject: [PATCH 14/15] [druntime: Clarify that DFLAGS_BASE in common.mak are an LDC extension] --- runtime/druntime/test/common.mak | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/druntime/test/common.mak b/runtime/druntime/test/common.mak index ed7e53b801..82831dd253 100644 --- a/runtime/druntime/test/common.mak +++ b/runtime/druntime/test/common.mak @@ -37,8 +37,10 @@ ifeq (,$(findstring ldmd2,$(DMD))) CFLAGS_BASE+=--target=x86_64-darwin-apple # ARM cpu is not supported by dmd endif endif -# LDC: include optional DFLAGS_BASE and use `-defaultlib=druntime-ldc [-link-defaultlib-shared]` instead of `-defaultlib= -L$(DRUNTIME[_IMPLIB])` -DFLAGS:=$(MODEL_FLAG) $(PIC) $(DFLAGS_BASE) -w -I../../src -I../../import -I$(SRC) -defaultlib=$(if $(findstring ldmd2,$(DMD)),druntime-ldc,) -preview=dip1000 $(if $(findstring $(OS),windows),,-L-lpthread -L-lm $(LINKDL)) +# LDC: +# * include optional DFLAGS_BASE +# * use `-defaultlib=druntime-ldc [-link-defaultlib-shared]` instead of `-defaultlib= -L$(DRUNTIME[_IMPLIB])` +DFLAGS:=$(MODEL_FLAG) $(PIC) $(if $(findstring ldmd2,$(DMD)),$(DFLAGS_BASE),) -w -I../../src -I../../import -I$(SRC) -defaultlib=$(if $(findstring ldmd2,$(DMD)),druntime-ldc,) -preview=dip1000 $(if $(findstring $(OS),windows),,-L-lpthread -L-lm $(LINKDL)) # LINK_SHARED may be set by importing makefile ifeq (,$(findstring ldmd2,$(DMD))) DFLAGS+=$(if $(LINK_SHARED),-L$(DRUNTIME_IMPLIB) $(if $(findstring $(OS),windows),-dllimport=all),-L$(DRUNTIME)) From 4d908d363369447cb84b143ee3279f64c450bc7f Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 20 Sep 2024 13:25:01 +0100 Subject: [PATCH 15/15] GHA: Switch to Xcode 16 final --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0dcb8fe504..3efced0f4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,9 +94,9 @@ jobs: with: submodules: true fetch-depth: 50 - - name: 'macOS 14: Switch to Xcode 16 Beta 6' + - name: 'macOS 14: Switch to Xcode 16' if: matrix.os == 'macos-14' - run: sudo xcode-select -switch /Applications/Xcode_16_beta_6.app + run: sudo xcode-select -switch /Applications/Xcode_16.app - name: Install prerequisites uses: ./.github/actions/1-setup with: