From 040cf4248dc1c6329cf08f73a46af13e140d4eb6 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 20 Aug 2023 23:32:51 -0700 Subject: [PATCH 1/3] gcc: simplify expression by applying workarounds more broadly This commit simplifies our gcc expression by applying various workarounds unconditionally, rather than only to exactly the versions which applied them prior to the deduplication cleanup. Unlike its predecessors https://github.com/NixOS/nixpkgs/pull/249707 and https://github.com/NixOS/nixpkgs/pull/250489 this commit *does* affect eval. --- pkgs/development/compilers/gcc/default.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index f467aa32f7d1..9105067fbc59 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -309,17 +309,15 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ libc = if libcCross != null then libcCross else stdenv.cc.libc; in ( - '' echo "fixing the \`GLIBC_DYNAMIC_LINKER'${lib.optionalString atLeast6 ", \\`UCLIBC_DYNAMIC_LINKER',"} and \`${if atLeast6 then "MUSL" else "UCLIBC"}_DYNAMIC_LINKER' macros..." + '' echo "fixing the \`{GLIBC,UCLIBC,MUSL}_DYNAMIC_LINKER macros..." for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h do grep -q ${lib.optionalString (!atLeast6) "LIBC"}_DYNAMIC_LINKER "$header" || continue echo " fixing \`$header'..." sed -i "$header" \ - -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g'${lib.optionalString atLeast6 " \\"} - '' + lib.optionalString atLeast6 '' -${""} -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' - '' + '' -${""} done + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \\ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done '' + lib.optionalString (atLeast6 && targetPlatform.libc == "musl") '' sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' '' @@ -327,9 +325,7 @@ ${""} done )) + lib.optionalString (atLeast7 && targetPlatform.isAvr) ('' makeFlagsArray+=( - '' + (lib.optionalString atLeast10 '' '-s' # workaround for hitting hydra log limit - '') + '' 'LIMITS_H_TEST=false' ) ''); From 80198b835b1fa20bab9b6a72d0e09c92e115d6e8 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 23 Aug 2023 00:14:01 -0700 Subject: [PATCH 2/3] gcc: remove backticks-used-as-quotes (error prone) --- pkgs/development/compilers/gcc/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 9105067fbc59..e6019ab13774 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -309,11 +309,11 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ libc = if libcCross != null then libcCross else stdenv.cc.libc; in ( - '' echo "fixing the \`{GLIBC,UCLIBC,MUSL}_DYNAMIC_LINKER macros..." + '' echo "fixing the {GLIBC,UCLIBC,MUSL}_DYNAMIC_LINKER macros..." for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h do grep -q ${lib.optionalString (!atLeast6) "LIBC"}_DYNAMIC_LINKER "$header" || continue - echo " fixing \`$header'..." + echo " fixing $header..." sed -i "$header" \ -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \\ -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' From af319af2254ce0dd303b03177875aaa52f25e265 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 23 Aug 2023 00:14:17 -0700 Subject: [PATCH 3/3] gcc: unescapify backslash --- pkgs/development/compilers/gcc/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index e6019ab13774..0e1b477f6372 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -315,7 +315,7 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ grep -q ${lib.optionalString (!atLeast6) "LIBC"}_DYNAMIC_LINKER "$header" || continue echo " fixing $header..." sed -i "$header" \ - -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \\ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' done '' + lib.optionalString (atLeast6 && targetPlatform.libc == "musl") ''