From f93119d9d3a2a8adb078892cbc7b33b47df5fb23 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 13 Feb 2024 01:32:39 +0100 Subject: [PATCH] macOS: Don't link lib{pthread,m} as platform libs --- .github/workflows/supported_llvm_versions.yml | 4 ++-- driver/linker-gcc.cpp | 9 +++++---- runtime/CMakeLists.txt | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/supported_llvm_versions.yml b/.github/workflows/supported_llvm_versions.yml index a571aad0850..21d4548413f 100644 --- a/.github/workflows/supported_llvm_versions.yml +++ b/.github/workflows/supported_llvm_versions.yml @@ -19,12 +19,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 -DD_COMPILER_FLAGS=-platformlib= -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 -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib + cmake_flags: -DBUILD_SHARED_LIBS=OFF -DD_COMPILER_FLAGS=-platformlib= -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib - job_name: Ubuntu 20.04, LLVM 15, latest LDC beta os: ubuntu-20.04 host_dc: ldc-beta diff --git a/driver/linker-gcc.cpp b/driver/linker-gcc.cpp index e56a89a5974..5af936ef877 100644 --- a/driver/linker-gcc.cpp +++ b/driver/linker-gcc.cpp @@ -670,8 +670,8 @@ void ArgsBuilder::addDefaultPlatformLibs() { switch (triple.getOS()) { case llvm::Triple::Linux: - addSoname = true; if (triple.getEnvironment() == llvm::Triple::Android) { + addSoname = true; args.push_back("-ldl"); args.push_back("-lm"); break; @@ -682,15 +682,16 @@ void ArgsBuilder::addDefaultPlatformLibs() { args.push_back("-lrt"); args.push_back("-ldl"); // fallthrough - case llvm::Triple::Darwin: - case llvm::Triple::MacOSX: case llvm::Triple::FreeBSD: case llvm::Triple::NetBSD: case llvm::Triple::OpenBSD: case llvm::Triple::DragonFly: - addSoname = true; args.push_back("-lpthread"); args.push_back("-lm"); + // fallthrough + case llvm::Triple::Darwin: + case llvm::Triple::MacOSX: + addSoname = true; break; case llvm::Triple::Solaris: diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index c0994cd34ec..ec9e4d869c8 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -125,6 +125,8 @@ if("${C_SYSTEM_LIBS}" STREQUAL "AUTO") set(C_SYSTEM_LIBS m pthread rt dl) elseif("${TARGET_SYSTEM}" MATCHES "FreeBSD") set(C_SYSTEM_LIBS m pthread execinfo z) + elseif("${TARGET_SYSTEM}" MATCHES "APPLE") + set(C_SYSTEM_LIBS ) else() set(C_SYSTEM_LIBS m pthread) endif()