-
Notifications
You must be signed in to change notification settings - Fork 87
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
language.c: bang into shape #102
base: main
Are you sure you want to change the base?
Conversation
name = "LD_LIBRARY_PATH"; | ||
prefix = "$DEVSHELL_DIR/lib"; | ||
name = "LIBRARY_PATH"; | ||
value = lib.concatStringsSep ":" (map (x: "${lib.getLib x}/lib") cfg.libraries); |
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.
value = "$DEVSHELL_DIR/lib";
does not work here?
Also how would programs build like this find their libraries at runtime? This is especially a problem when you run outside of devshell.
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.
How about setting NIX_LDFLAGS="-rpath $DEVSHELL_DIR/lib";
description = '' | ||
Which C compiler to use. | ||
|
||
For gcc, use pkgs.gcc-unwrapped. |
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.
Having a wrapped and a unwrapped version will behave quite differently here. i.e. the wrapped version of clang will set hardening flags that the unwrapped version of gcc won't. This might be surprising for users.
prefix = "$DEVSHELL_DIR/include"; | ||
}) | ||
++ (lib.optional cfg.pkg-config { | ||
name = "PKG_CONFIG_PATH"; |
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.
You also want to set CC/CXX/LD. Otherwise many buildsystems will default to something like CC = /usr/bin/gcc
libraries = mkOption { | ||
type = types.listOf strOrPackage; | ||
default = [ ]; | ||
description = "Use this when another language dependens on a dynamic library"; | ||
example = lib.literalExample '' | ||
[ pkgs.glibc ] |
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.
Does glibc in libraries have any effect when a wrapped clang is used?
For testing: https://github.com/Mic92/build-system-koans |
I'm a bit overwhelmed by the complexity of this work and don't think I can do a good job at it. If somebody wants to take over, I would be happy. |
Maybe we can talk about this next year. |
A few learning:
ld
uses LIBRARY_PATH, not LD_LIBRARY_PATH to find object files. Link to thelibraries directly to minimize rebuilds.
pkgs.gcc
doesn't expose the gcov binary.pkgs.gcc
is heavily tweaked towork with the nixpkgs stdenv so use
pkgs.gcc-unwrapped
instead.Made
pkg-config
optional, it's not used all the time.