Skip to content

Commit

Permalink
bintools,gcc: introduce mlibc support
Browse files Browse the repository at this point in the history
In gcc, libsanitize is disabled because mlibc doesn't support
libsanitize yet but upstream is working on it. Patches needed for gcc to
support linux-mlibc targets are pulled from managarm's fork of gcc,
patches only needed by managarm are not applied.
  • Loading branch information
lzcunt committed Jan 5, 2025
1 parent 9a4715a commit c19c839
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkgs/build-support/bintools-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ let
# shell glob that ought to match it.
dynamicLinker =
/**/ if sharedLibraryLoader == null then ""
else if targetPlatform.libc == "mlibc" then "${sharedLibraryLoader}/lib/ld.so"
else if targetPlatform.libc == "musl" then "${sharedLibraryLoader}/lib/ld-musl-*"
else if targetPlatform.libc == "uclibc" then "${sharedLibraryLoader}/lib/ld*-uClibc.so.1"
else if (targetPlatform.libc == "bionic" && targetPlatform.is32bit) then "/system/bin/linker"
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/compilers/gcc/common/configure-flags.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ let
else if targetPlatform.isWindows then (threadsCross.model or "win32")
else "single"}"
"--enable-nls"
] ++ lib.optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
] ++ lib.optionals (lib.elem targetPlatform.libc [ "mlibc" "musl" "uclibc" ]) [
# libsanitizer requires netrom/netrom.h which is not
# available in uclibc.
"--disable-libsanitizer"
Expand Down Expand Up @@ -217,6 +217,7 @@ let
# On Illumos/Solaris GNU as is preferred
"--with-gnu-as" "--without-gnu-ld"
]
++ lib.optional (targetPlatform.libc == "mlibc") "--disable-libsanitizer"
++ lib.optional (targetPlatform.libc == "musl")
# musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865
"--disable-libmpx"
Expand Down
12 changes: 12 additions & 0 deletions pkgs/development/compilers/gcc/patches/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ in
})
]

## mlibc
++ optionals (stdenv.targetPlatform.isMlibc && atLeast14) [
(fetchpatch {
url = "https://github.com/managarm/gcc/commit/092cb31af8ed12dbecc02327444f030a7c40c344.diff";
hash = "sha256-Ix95v0UxC73tfW2UliWiRgS0wC1wVUo5waM38qFlRFM=";
})
(fetchpatch {
url = "https://github.com/managarm/gcc/commit/b5cdfff8afc4a668e65541eec5b512d080116a43.diff";
hash = "sha256-0xbw/vRbUvsIIhXM8iyAxm2FWXDnYXblAJ1gFEgeOPg=";
})
]

## Darwin

# Fixes detection of Darwin on x86_64-darwin. Otherwise, GCC uses a deployment target of 10.5, which crashes ld64.
Expand Down

0 comments on commit c19c839

Please sign in to comment.