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 <[email protected]>
This commit is contained in:
sdomiandNico Weber authored and Nico Weber committed 2024-08-04 11:09:53 -04:00
1 parent cb10f70394
commit 4db8a0b964
8 files changed
+18 -20

No files matched your search

@@ -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 @@
-1
View File
@@ -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'
@@ -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
-2
View File
@@ -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[@]}"
}
@@ -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
+1 -1
View File
@@ -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
}
+1 -2
View File
@@ -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"
}
@@ -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