C: Difference between revisions

imported>Mic92
short passage about cross-compiling
imported>Mic92
mention debug symbols
Line 180: Line 180:
== Cross-Compiling ==
== Cross-Compiling ==


To get access to a cross-compiling toolchain use `pkgsCross` prefix.
To get access to a cross-compiling toolchain use <code>pkgsCross</code> prefix.
In this example we load the compiler for the arm-embedded target (bare metal without operating system):
In this example we load the compiler for the arm-embedded target (bare metal without operating system):


Line 199: Line 199:
Well behaved build systems should respect these environment variables when building projects.
Well behaved build systems should respect these environment variables when building projects.
Also take a look in the [[Cross Compiling]] article for further information on cross-compiling.
Also take a look in the [[Cross Compiling]] article for further information on cross-compiling.
== Debug symbols ==
By default debug symbols are stripped of in the fixup phase of a package build.
To get a library with debug symbols one can use the <code>enableDebugging</code>
function to disable stripping:
<syntaxHighlight lang=nix>
with import <nixpkgs> {};
stdenv.mkDerivation {
  name = "env";
  buildInputs = [ (enableDebugging zlib) ]; 
}
</syntaxHighlight>
<syntaxHighlight lang=console>
$ echo $NIX_LDFLAGS
-rpath /nix/store/fqpmgpcij4dddckkw4wh53ffn31yv1y6-env/lib64 -rpath /nix/store/fqpmgpcij4dddckkw4wh53ffn31yv1y6-env/lib  -L/nix/store/g2y1122bwz5434w6nx34s40f2hmdkb1z-zlib-1.2.11/lib -L/nix/store/g2y1122bwz5434w6nx34s40f2hmdkb1z-zlib-1.2.11/lib
$ file /nix/store/g2y1122bwz5434w6nx34s40f2hmdkb1z-zlib-1.2.11/lib/libz.so.1.2.11
/nix/store/g2y1122bwz5434w6nx34s40f2hmdkb1z-zlib-1.2.11/lib/libz.so.1.2.11: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
</syntaxHighlight>
It also possible to separate debug symbols from the actual binaries and store them in a different output by using the  <code>separateDebugInfo</code> option.
This is described in the [https://nixos.org/nixpkgs/manual/#ssec-fixup-phase manual].
Also see [[Debug Symbols]] for further information about debug symbols.