-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llvmPackages.libc: init at 20.0.0-unstable-2024-12-08 #363449
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,6 +416,9 @@ rec { | |
uclibceabihf = { float = "hard"; }; | ||
uclibc = {}; | ||
|
||
# LLVM libc | ||
llvm = {}; | ||
|
||
unknown = {}; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
llvm_meta, | ||
src ? null, | ||
monorepoSrc ? null, | ||
version, | ||
release_version, | ||
runCommand, | ||
python3, | ||
python3Packages, | ||
patches ? [ ], | ||
cmake, | ||
ninja, | ||
isFullBuild ? true, | ||
linuxHeaders, | ||
}: | ||
let | ||
pname = "libc"; | ||
|
||
src' = runCommand "${pname}-src-${version}" { } ('' | ||
mkdir -p "$out" | ||
cp -r ${monorepoSrc}/cmake "$out" | ||
cp -r ${monorepoSrc}/runtimes "$out" | ||
cp -r ${monorepoSrc}/llvm "$out" | ||
cp -r ${monorepoSrc}/${pname} "$out" | ||
''); | ||
|
||
stdenv' = | ||
if stdenv.cc.isClang then | ||
stdenv.override { | ||
cc = stdenv.cc.override { | ||
nixSupport = stdenv.cc.nixSupport // { | ||
cc-cflags = lib.remove "-lunwind" stdenv.cc.nixSupport.cc-cflags; | ||
}; | ||
}; | ||
} | ||
else | ||
stdenv; | ||
in | ||
stdenv'.mkDerivation (finalAttrs: { | ||
inherit pname version patches; | ||
|
||
src = src'; | ||
|
||
sourceRoot = "${finalAttrs.src.name}/runtimes"; | ||
|
||
nativeBuildInputs = | ||
[ | ||
cmake | ||
python3 | ||
] | ||
++ (lib.optional (lib.versionAtLeast release_version "15") ninja) | ||
++ (lib.optional isFullBuild python3Packages.pyyaml); | ||
|
||
buildInputs = lib.optional isFullBuild linuxHeaders; | ||
|
||
outputs = [ "out" ] ++ (lib.optional isFullBuild "dev"); | ||
|
||
postUnpack = lib.optionalString isFullBuild '' | ||
patchShebangs $sourceRoot/../$pname/hdrgen/yaml_to_classes.py | ||
chmod +x $sourceRoot/../$pname/hdrgen/yaml_to_classes.py | ||
''; | ||
|
||
prePatch = '' | ||
cd ../${finalAttrs.pname} | ||
chmod -R u+w ../ | ||
''; | ||
|
||
postPatch = '' | ||
cd ../runtimes | ||
''; | ||
|
||
postInstall = lib.optionalString (!isFullBuild) '' | ||
substituteAll ${./libc-shim.so} $out/lib/libc.so | ||
''; | ||
|
||
libc = if (!isFullBuild) then stdenv.cc.libc else null; | ||
|
||
cmakeFlags = [ | ||
(lib.cmakeBool "LLVM_LIBC_FULL_BUILD" isFullBuild) | ||
(lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc") | ||
]; | ||
|
||
# For the update script: | ||
passthru = { | ||
monorepoSrc = monorepoSrc; | ||
inherit isFullBuild; | ||
}; | ||
|
||
meta = llvm_meta // { | ||
homepage = "https://libc.llvm.org/"; | ||
description = "Standard C library for LLVM"; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GROUP (@libc@ @out@/lib/libllvmlibc.a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this attribute being for two different things depending on the platform is going to be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbf, we already have attributes which confuse people.
clangUseLLVM
,compiler-rt
,stdenv
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that's justification to make things more confusing??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I think it's not that confusing, it'll cause some accidents until someone realizes which one they should use if they need it. The lib names are different between the two so someone could easily tell when things go wrong when an error happens. Also, documenting the attributes better would help a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why not make it explicit whether full or overlay is being used? As we've established, they're used completely differently, so there isn't a situation where you'd want an attribute that was sometimes the overlay and sometimes full.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was having a shim which adds in both inside the overlay mode. Then the function which selects the libc cross could detect when to use the overlay mode. That could allow for mixing LLVM libc and glibc or LLVM libc and musl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I know, a shim can be made by writing a linker script into
libc.so
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then how about we hold off on this attribute until that's ready to go? It's not really useful as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the shim.