From 4db8a0b964725bb29733e41278d75ac3f58a31a4 Mon Sep 17 00:00:00 2001 From: sdomi Date: Fri, 2 Aug 2024 02:04:59 +0200 Subject: [PATCH] Toolchain: Fix default library paths when building with clang When building with the GNU toolchain, /usr/local/lib and /usr/local/include are among the default search paths for the compiler and linker. It seems that this is not the case for Clang/LLVM, and thus some packages fail to build, while others silently drop optional deps. This commit adds those paths back, fixing multiple packages at once. Additionally, it removes legacy -I/-L includes in various Ports which are no longer needed. Co-Authored-By: Nico Weber --- ...lchain-information-and-makefile-file.patch | 19 ++++++++----------- Ports/git/package.sh | 1 - ...e-it-build-with-SDL-2-instead-of-1.2.patch | 2 +- Ports/openssl/package.sh | 2 -- ...he-SDL2-include-path-and-library-dir.patch | 2 +- Ports/sl/package.sh | 2 +- Ports/stress-ng/package.sh | 3 +-- ...001-clang-Add-support-for-SerenityOS.patch | 7 ++++++- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Ports/epsilon/patches/0001-Add-serenity-toolchain-information-and-makefile-file.patch b/Ports/epsilon/patches/0001-Add-serenity-toolchain-information-and-makefile-file.patch index 9825fa2262e..3331ba188fc 100644 --- a/Ports/epsilon/patches/0001-Add-serenity-toolchain-information-and-makefile-file.patch +++ b/Ports/epsilon/patches/0001-Add-serenity-toolchain-information-and-makefile-file.patch @@ -4,17 +4,17 @@ Date: Tue, 13 Jul 2021 21:17:44 +0200 Subject: [PATCH] Add serenity toolchain information and makefile files --- - build/platform.simulator.serenity.mak | 6 ++++ - build/toolchain.x86_64-pc-serenity.mak | 4 +++ - ion/src/simulator/serenity/Makefile | 43 +++++++++++++++++++++++++++ - 3 files changed, 53 insertions(+) + build/platform.simulator.serenity.mak | 6 ++++ + build/toolchain.x86_64-pc-serenity.mak | 1 + + ion/src/simulator/serenity/Makefile | 43 ++++++++++++++++++++++++++ + 3 files changed, 50 insertions(+) create mode 100644 build/platform.simulator.serenity.mak create mode 100644 build/toolchain.x86_64-pc-serenity.mak create mode 100644 ion/src/simulator/serenity/Makefile diff --git a/build/platform.simulator.serenity.mak b/build/platform.simulator.serenity.mak new file mode 100644 -index 0000000..ff985de +index 0000000000000000000000000000000000000000..0ac83c0bb06554bfa3077b9c2b67516291018e3b --- /dev/null +++ b/build/platform.simulator.serenity.mak @@ -0,0 +1,6 @@ @@ -26,17 +26,14 @@ index 0000000..ff985de +SHOULD_USE_DYNAMIC_SDL = 1 diff --git a/build/toolchain.x86_64-pc-serenity.mak b/build/toolchain.x86_64-pc-serenity.mak new file mode 100644 -index 0000000..d6110e2 +index 0000000000000000000000000000000000000000..bb49f4ed4dcec21891f94ec9c3c9f602d6f4cbcf --- /dev/null +++ b/build/toolchain.x86_64-pc-serenity.mak -@@ -0,0 +1,4 @@ +@@ -0,0 +1 @@ +TOOLCHAIN_PREFIX = x86_64-pc-serenity -+CC = $(TOOLCHAIN_PREFIX)-gcc -+CXX = $(TOOLCHAIN_PREFIX)-g++ -+LD = $(TOOLCHAIN_PREFIX)-g++ diff --git a/ion/src/simulator/serenity/Makefile b/ion/src/simulator/serenity/Makefile new file mode 100644 -index 0000000..5d4bb13 +index 0000000000000000000000000000000000000000..5d4bb131983ba85c79042cfa790b94e400158705 --- /dev/null +++ b/ion/src/simulator/serenity/Makefile @@ -0,0 +1,43 @@ diff --git a/Ports/git/package.sh b/Ports/git/package.sh index 13648d47963..d3cfbda74c9 100755 --- a/Ports/git/package.sh +++ b/Ports/git/package.sh @@ -9,7 +9,6 @@ configopts=( "--target=${SERENITY_ARCH}-pc-serenity" "--with-lib=${SERENITY_INSTALL_ROOT}/usr/local" 'CFLAGS=-DNO_IPV6' - "LDFLAGS=-L${SERENITY_INSTALL_ROOT}/usr/local/lib" ) depends=( 'curl' diff --git a/Ports/ja2/patches/0001-Make-it-build-with-SDL-2-instead-of-1.2.patch b/Ports/ja2/patches/0001-Make-it-build-with-SDL-2-instead-of-1.2.patch index da101f0437f..f454f820eae 100644 --- a/Ports/ja2/patches/0001-Make-it-build-with-SDL-2-instead-of-1.2.patch +++ b/Ports/ja2/patches/0001-Make-it-build-with-SDL-2-instead-of-1.2.patch @@ -176,7 +176,7 @@ index 6db811f..53103d3 100644 +# using Serenity SDL2 library +ifdef SERENITY +CFLAGS_SDL= -I${SERENITY_BUILD_DIR}/Root/usr/local/include/SDL2 -D_REENTRANT -+LDFLAGS_SDL= -L${SERENITY_BUILD_DIR}/Root/usr/local/lib -lSDL2 ++LDFLAGS_SDL= -lSDL2 +endif + # using system SDL library diff --git a/Ports/openssl/package.sh b/Ports/openssl/package.sh index d662248aa50..fbd756552bf 100755 --- a/Ports/openssl/package.sh +++ b/Ports/openssl/package.sh @@ -21,8 +21,6 @@ configopts=( ) configure() { - export CFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/local/include" - export LDFLAGS="-L${SERENITY_INSTALL_ROOT}/usr/local/lib" run ./"${configscript}" "${configopts[@]}" } diff --git a/Ports/sam/patches/0002-Manually-set-the-SDL2-include-path-and-library-dir.patch b/Ports/sam/patches/0002-Manually-set-the-SDL2-include-path-and-library-dir.patch index 40ce22eaa88..4ecf5e713aa 100644 --- a/Ports/sam/patches/0002-Manually-set-the-SDL2-include-path-and-library-dir.patch +++ b/Ports/sam/patches/0002-Manually-set-the-SDL2-include-path-and-library-dir.patch @@ -18,7 +18,7 @@ index 1153e0c..da26e9d 100644 -CFLAGS = -Wall -O2 -DUSESDL `sdl-config --cflags` -LFLAGS = `sdl-config --libs` +CFLAGS = -Wall -O2 -DUSESDL -I$(SERENITY_INSTALL_ROOT)/usr/local/include/SDL2 -D_REENTRANT -+LFLAGS = -L$(SERENITY_INSTALL_ROOT)/usr/local/lib -lSDL2 ++LFLAGS = -lSDL2 # no libsdl present #CFLAGS = -Wall -O2 diff --git a/Ports/sl/package.sh b/Ports/sl/package.sh index 3c21c58a7fb..b4190ace262 100755 --- a/Ports/sl/package.sh +++ b/Ports/sl/package.sh @@ -8,5 +8,5 @@ files=( depends=("ncurses") build() { - run ${CC} -I${SERENITY_INSTALL_ROOT}/usr/local/include/ncurses -L${SERENITY_INSTALL_ROOT}/usr/local/lib -o sl sl.c -lncurses -ltinfo + run ${CC} -I${SERENITY_INSTALL_ROOT}/usr/local/include/ncurses -o sl sl.c -lncurses -ltinfo } diff --git a/Ports/stress-ng/package.sh b/Ports/stress-ng/package.sh index bb21c44c31b..f2ef7bafb8a 100755 --- a/Ports/stress-ng/package.sh +++ b/Ports/stress-ng/package.sh @@ -9,6 +9,5 @@ depends=( ) pre_configure() { - export CFLAGS="-I${SERENITY_INSTALL_ROOT}/usr/local/include" - export LDFLAGS="-L${SERENITY_INSTALL_ROOT}/usr/local/lib -lzlib" + export LDFLAGS="-lzlib" } diff --git a/Toolchain/Patches/llvm/0001-clang-Add-support-for-SerenityOS.patch b/Toolchain/Patches/llvm/0001-clang-Add-support-for-SerenityOS.patch index 4be61f1fc46..652d760985b 100644 --- a/Toolchain/Patches/llvm/0001-clang-Add-support-for-SerenityOS.patch +++ b/Toolchain/Patches/llvm/0001-clang-Add-support-for-SerenityOS.patch @@ -180,7 +180,7 @@ new file mode 100644 index 000000000000..2167758100bc --- /dev/null +++ b/clang/lib/Driver/ToolChains/Serenity.cpp -@@ -0,0 +1,216 @@ +@@ -0,0 +1,221 @@ +//===---- Serenity.cpp - SerenityOS ToolChain Implementation ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -343,6 +343,8 @@ index 000000000000..2167758100bc + CmdArgs.push_back("--pop-state"); + } + ++ CmdArgs.push_back("-L=/usr/local/lib"); ++ + // Silence warnings when linking C code with a C++ '-stdlib' argument. + Args.ClaimAllArgs(options::OPT_stdlib_EQ); + @@ -395,6 +397,9 @@ index 000000000000..2167758100bc + if (DriverArgs.hasArg(options::OPT_nostdlibinc)) + return; + ++ addSystemInclude( ++ DriverArgs, CC1Args, concat(D.SysRoot, "/usr/local/include")); ++ + addSystemInclude(DriverArgs, CC1Args, concat(D.SysRoot, "/usr/include")); +} diff --git a/clang/lib/Driver/ToolChains/Serenity.h b/clang/lib/Driver/ToolChains/Serenity.h