From 717e7bd2919620e06e3c97154216d68c28276c0b Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 7 Aug 2022 17:31:27 +0100 Subject: [PATCH] tree-sitter: strip only debug info by default Noticed use of $STRIP when passed through various uses of $STRIP in `nixpkgs`. This looked unusual in a way that it strips not just debugging symbols but also all the rest. The change switch to debug-only stripping. While at it switched to expliict use of `-fPIC` for shared library. --- .../tools/parsing/tree-sitter/grammar.nix | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pkgs/development/tools/parsing/tree-sitter/grammar.nix b/pkgs/development/tools/parsing/tree-sitter/grammar.nix index 96486c0c2b50..110f37a5aa89 100644 --- a/pkgs/development/tools/parsing/tree-sitter/grammar.nix +++ b/pkgs/development/tools/parsing/tree-sitter/grammar.nix @@ -30,16 +30,18 @@ stdenv.mkDerivation rec { CFLAGS = [ "-I${src}/src" "-O2" ]; CXXFLAGS = [ "-I${src}/src" "-O2" ]; + stripDebugList = [ "parser" ]; + # When both scanner.{c,cc} exist, we should not link both since they may be the same but in # different languages. Just randomly prefer C++ if that happens. buildPhase = '' runHook preBuild if [[ -e "$src/src/scanner.cc" ]]; then - $CXX -c "$src/src/scanner.cc" -o scanner.o $CXXFLAGS + $CXX -fPIC -c "$src/src/scanner.cc" -o scanner.o $CXXFLAGS elif [[ -e "$src/src/scanner.c" ]]; then - $CC -c "$src/src/scanner.c" -o scanner.o $CFLAGS + $CC -fPIC -c "$src/src/scanner.c" -o scanner.o $CFLAGS fi - $CC -c "$src/src/parser.c" -o parser.o $CFLAGS + $CC -fPIC -c "$src/src/parser.c" -o parser.o $CFLAGS $CXX -shared -o parser *.o runHook postBuild ''; @@ -50,11 +52,4 @@ stdenv.mkDerivation rec { mv parser $out/ runHook postInstall ''; - - # Strip failed on darwin: strip: error: symbols referenced by indirect symbol table entries that can't be stripped - fixupPhase = lib.optionalString stdenv.isLinux '' - runHook preFixup - $STRIP $out/parser - runHook postFixup - ''; }