diff --git a/.github/actions/7-package/action.yml b/.github/actions/7-package/action.yml index 569e5b6922..6e31581d00 100644 --- a/.github/actions/7-package/action.yml +++ b/.github/actions/7-package/action.yml @@ -24,13 +24,6 @@ runs: fi echo "DMD=$DMD" >> $GITHUB_ENV - - name: 'Alpine: Set DFLAGS environment variable (-Xcc=-static)' # for fully statically linked dub etc. - if: inputs.os == 'alpine' - shell: bash - run: | - set -eux - echo "DFLAGS=-Xcc=-static${DFLAGS:+ $DFLAGS}" >> $GITHUB_ENV - - name: Build & copy dub shell: bash run: | @@ -56,6 +49,11 @@ runs: cd dlang-tools git checkout "$(cat ../ldc/packaging/dlang-tools_version)" + # Alpine: build these tools as fully static executables + if [[ '${{ inputs.os }}' == 'alpine' ]]; then + export DFLAGS="-Xcc=-static${DFLAGS:+ $DFLAGS}" + fi + mkdir bin $DMD -w -de -dip1000 rdmd.d -of=bin/rdmd $DMD -w -de -dip1000 ddemangle.d -of=bin/ddemangle diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff292b2bea..e38dee4c2c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: -DBUILD_LTO_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ + -DD_LINKER_ARGS=-static-libstdc++ -DJITRT_EXTRA_LDFLAGS=-static-libstdc++ -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full @@ -47,7 +47,7 @@ jobs: -DCOMPILER_RT_LIBDIR_OS=aarch64-unknown-linux-gnu -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ + -DD_LINKER_ARGS=-static-libstdc++ -DJITRT_EXTRA_LDFLAGS=-static-libstdc++ -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full @@ -69,7 +69,7 @@ jobs: -DCOMPILER_RT_LIBDIR_OS=linux -DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=x86_64 -DTEST_COMPILER_RT_LIBRARIES="profile;lsan;asan;msan;fuzzer" - -DCMAKE_EXE_LINKER_FLAGS=-static + -DD_LINKER_ARGS=-static -DD_COMPILER_FLAGS="-O -flto=full" # FIXME: -defaultlib=phobos2-ldc-lto,druntime-ldc-lto with_pgo: false diff --git a/.github/workflows/supported_llvm_versions.yml b/.github/workflows/supported_llvm_versions.yml index bcda36dd02..346b9a7a82 100644 --- a/.github/workflows/supported_llvm_versions.yml +++ b/.github/workflows/supported_llvm_versions.yml @@ -24,12 +24,12 @@ 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 -DD_LINKER_ARGS=-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 -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 -DD_LINKER_ARGS=-L/opt/homebrew/opt/zstd/lib -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++ - job_name: Ubuntu 24.04, LLVM 15, latest DMD beta os: ubuntu-24.04 host_dc: dmd-beta diff --git a/cmake/Modules/BuildDExecutable.cmake b/cmake/Modules/BuildDExecutable.cmake index d5ee8cddf8..fe71780b8c 100644 --- a/cmake/Modules/BuildDExecutable.cmake +++ b/cmake/Modules/BuildDExecutable.cmake @@ -95,7 +95,7 @@ function(build_d_executable target_name output_exe d_src_files compiler_args lin list(APPEND dep_libs "-L$") endforeach() - set(full_linker_args ${CMAKE_EXE_LINKER_FLAGS} ${linker_args}) + set(full_linker_args ${CMAKE_EXE_LINKER_FLAGS} ${linker_args} ${D_LINKER_ARGS}) translate_linker_args(full_linker_args translated_linker_args) # We need to link against the C++ runtime library.