diff --git a/pkgs/development/compilers/gcc/ng/15/gcc/0001-find_a_program-First-search-with-machine-prefix.patch b/pkgs/development/compilers/gcc/ng/15/gcc/0001-find_a_program-First-search-with-machine-prefix.patch deleted file mode 100644 index 46eb8d03b89a..000000000000 --- a/pkgs/development/compilers/gcc/ng/15/gcc/0001-find_a_program-First-search-with-machine-prefix.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 3af17de3a5f6acd5a2f9340d84b8667459f43eea Mon Sep 17 00:00:00 2001 -From: John Ericson -Date: Wed, 18 Aug 2021 01:55:31 -0400 -Subject: [PATCH 1/3] find_a_program: First search with machine prefix - -This matches the behavior of Clang, and makes it easier to work with -cross compilers without heeding to hard-code paths at build time. ---- - gcc/gcc.cc | 78 +++++++++++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 68 insertions(+), 10 deletions(-) - -diff --git a/gcc/gcc.cc b/gcc/gcc.cc -index 4fd87f2c4a1..55738d258b3 100644 ---- a/gcc/gcc.cc -+++ b/gcc/gcc.cc -@@ -1600,6 +1600,11 @@ static const char *machine_suffix = 0; - - static const char *just_machine_suffix = 0; - -+/* Prefix to attach to *basename* of commands being searched. -+ This is just `MACHINE-'. */ -+ -+static const char *just_machine_prefix = 0; -+ - /* Adjusted value of GCC_EXEC_PREFIX envvar. */ - - static const char *gcc_exec_prefix; -@@ -3043,15 +3048,6 @@ file_at_path (char *path, void *data) - memcpy (path + len, info->name, info->name_len); - len += info->name_len; - -- /* Some systems have a suffix for executable files. -- So try appending that first. */ -- if (info->suffix_len) -- { -- memcpy (path + len, info->suffix, info->suffix_len + 1); -- if (access_check (path, info->mode) == 0) -- return path; -- } -- - path[len] = '\0'; - if (access_check (path, info->mode) == 0) - return path; -@@ -3091,12 +3087,52 @@ find_a_file (const struct path_prefix *pprefix, const char *name, int mode, - file_at_path, &info); - } - -+/* Callback for find_a_program. Appends the file name to the directory -+ path. Like file_at_path but tries machine prefix and exe suffix too. */ -+ -+static void * -+program_at_path (char *path, void *data) -+{ -+ /* try first with machine-prefixed name */ -+ struct file_at_path_info *info = (struct file_at_path_info *) data; -+ size_t path_len = strlen (path); -+ -+ for (auto prefix : { just_machine_prefix, "" }) -+ { -+ auto len = path_len; -+ -+ auto prefix_len = strlen(prefix); -+ memcpy (path + len, prefix, prefix_len); -+ len += prefix_len; -+ -+ memcpy (path + len, info->name, info->name_len); -+ len += info->name_len; -+ -+ /* Some systems have a suffix for executable files. -+ So try appending that first. */ -+ if (info->suffix_len) -+ { -+ memcpy (path + len, info->suffix, info->suffix_len + 1); -+ if (access_check (path, info->mode) == 0) -+ return path; -+ } -+ -+ path[len] = '\0'; -+ if (access_check (path, info->mode) == 0) -+ return path; -+ } -+ -+ return NULL; -+} -+ - /* Specialization of find_a_file for programs that also takes into account - configure-specified default programs. */ - - static char* - find_a_program (const char *name) - { -+ const int mode = X_OK; -+ - /* Do not search if default matches query. */ - - #ifdef DEFAULT_ASSEMBLER -@@ -3114,7 +3150,28 @@ find_a_program (const char *name) - return xstrdup (DEFAULT_DSYMUTIL); - #endif - -- return find_a_file (&exec_prefixes, name, X_OK, false); -+ /* Find the filename in question (special case for absolute paths). */ -+ -+ if (IS_ABSOLUTE_PATH (name)) -+ { -+ if (access (name, mode) == 0) -+ return xstrdup (name); -+ -+ return NULL; -+ } -+ -+ struct file_at_path_info info; -+ -+ info.name = name; -+ info.suffix = HOST_EXECUTABLE_SUFFIX; -+ info.name_len = strlen (info.name); -+ info.suffix_len = strlen (info.suffix); -+ info.mode = mode; -+ -+ return (char*) for_each_path ( -+ &exec_prefixes, false, -+ info.name_len + info.suffix_len + strlen(just_machine_prefix), -+ program_at_path, &info); - } - - /* Ranking of prefixes in the sort list. -B prefixes are put before -@@ -8492,6 +8549,7 @@ driver::set_up_specs () const - machine_suffix = concat (spec_host_machine, dir_separator_str, spec_version, - accel_dir_suffix, dir_separator_str, NULL); - just_machine_suffix = concat (spec_machine, dir_separator_str, NULL); -+ just_machine_prefix = concat (spec_machine, "-", NULL); - - specs_file = find_a_file (&startfile_prefixes, "specs", R_OK, true); - /* Read the specs file unless it is a default one. */ --- -2.47.2 - diff --git a/pkgs/development/compilers/gcc/ng/15/gcc/0002-driver-for_each_pass-Pass-to-callback-whether-dir-is.patch b/pkgs/development/compilers/gcc/ng/15/gcc/0002-driver-for_each_pass-Pass-to-callback-whether-dir-is.patch deleted file mode 100644 index e0f295f8b88c..000000000000 --- a/pkgs/development/compilers/gcc/ng/15/gcc/0002-driver-for_each_pass-Pass-to-callback-whether-dir-is.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 8e1b7a128a69393c6d3f53b8f66bd52c6bbce908 Mon Sep 17 00:00:00 2001 -From: John Ericson -Date: Wed, 18 Aug 2021 01:55:45 -0400 -Subject: [PATCH 2/3] driver: for_each_pass: Pass to callback whether dir is - machine-disambiguated - -We will use this in the subsequent diff to control what basenames we -search for. In machine-specific subdirectories, we should just look for -the original basename, but in machine-agnostic subdirectories, we might -additionally look for prefixed disambiguated names, as an alternate -method of keeping targets apart. ---- - gcc/gcc.cc | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) - -diff --git a/gcc/gcc.cc b/gcc/gcc.cc -index 55738d258b3..f9f83d1a804 100644 ---- a/gcc/gcc.cc -+++ b/gcc/gcc.cc -@@ -2783,7 +2783,7 @@ static void * - for_each_path (const struct path_prefix *paths, - bool do_multi, - size_t extra_space, -- void *(*callback) (char *, void *), -+ void *(*callback) (char *, bool, void *), - void *callback_info) - { - struct prefix_list *pl; -@@ -2844,7 +2844,7 @@ for_each_path (const struct path_prefix *paths, - if (!skip_multi_dir) - { - memcpy (path + len, multi_suffix, suffix_len + 1); -- ret = callback (path, callback_info); -+ ret = callback (path, true, callback_info); - if (ret) - break; - } -@@ -2855,7 +2855,7 @@ for_each_path (const struct path_prefix *paths, - && pl->require_machine_suffix == 2) - { - memcpy (path + len, just_multi_suffix, just_suffix_len + 1); -- ret = callback (path, callback_info); -+ ret = callback (path, true, callback_info); - if (ret) - break; - } -@@ -2865,7 +2865,7 @@ for_each_path (const struct path_prefix *paths, - && !pl->require_machine_suffix && multiarch_dir) - { - memcpy (path + len, multiarch_suffix, multiarch_len + 1); -- ret = callback (path, callback_info); -+ ret = callback (path, true, callback_info); - if (ret) - break; - } -@@ -2893,7 +2893,7 @@ for_each_path (const struct path_prefix *paths, - else - path[len] = '\0'; - -- ret = callback (path, callback_info); -+ ret = callback (path, false, callback_info); - if (ret) - break; - } -@@ -2948,7 +2948,7 @@ struct add_to_obstack_info { - }; - - static void * --add_to_obstack (char *path, void *data) -+add_to_obstack (char *path, bool, void *data) - { - struct add_to_obstack_info *info = (struct add_to_obstack_info *) data; - -@@ -3040,7 +3040,7 @@ struct file_at_path_info { - }; - - static void * --file_at_path (char *path, void *data) -+file_at_path (char *path, bool, void *data) - { - struct file_at_path_info *info = (struct file_at_path_info *) data; - size_t len = strlen (path); -@@ -3091,7 +3091,7 @@ find_a_file (const struct path_prefix *pprefix, const char *name, int mode, - path. Like file_at_path but tries machine prefix and exe suffix too. */ - - static void * --program_at_path (char *path, void *data) -+program_at_path (char *path, bool machine_specific, void *data) - { - /* try first with machine-prefixed name */ - struct file_at_path_info *info = (struct file_at_path_info *) data; -@@ -6074,7 +6074,7 @@ struct spec_path_info { - }; - - static void * --spec_path (char *path, void *data) -+spec_path (char *path, bool, void *data) - { - struct spec_path_info *info = (struct spec_path_info *) data; - size_t len = 0; --- -2.47.2 - diff --git a/pkgs/development/compilers/gcc/ng/15/gcc/0003-find_a_program-Only-search-for-prefixed-paths-in-und.patch b/pkgs/development/compilers/gcc/ng/15/gcc/0003-find_a_program-Only-search-for-prefixed-paths-in-und.patch deleted file mode 100644 index 8fd83506b4d4..000000000000 --- a/pkgs/development/compilers/gcc/ng/15/gcc/0003-find_a_program-Only-search-for-prefixed-paths-in-und.patch +++ /dev/null @@ -1,75 +0,0 @@ -From e1ee1a2df1ad32de24e8fdaeac0a533681710578 Mon Sep 17 00:00:00 2001 -From: John Ericson -Date: Wed, 18 Aug 2021 01:55:52 -0400 -Subject: [PATCH 3/3] find_a_program: Only search for prefixed paths in - undisambiguated dirs - -This means, we might search for: - -- path/$machine/$version/prog -- path/$machine/prog -- path/$machine-prog - -But not - -- path/$machine/$version/$machine-prog - -because disambiguating $machine twice is unnecessary. - -This does mean we less liberal in what we accept than LLVM, but that's -OK. The down side of always Postel's law is everyone converges on -accepting all sorts of garbage, which makes debugging end-to-end hard -when mistakes are not caught early. ---- - gcc/gcc.cc | 25 ++++++++++++++++--------- - 1 file changed, 16 insertions(+), 9 deletions(-) - -diff --git a/gcc/gcc.cc b/gcc/gcc.cc -index f9f83d1a804..d837b6ea779 100644 ---- a/gcc/gcc.cc -+++ b/gcc/gcc.cc -@@ -3097,15 +3097,9 @@ program_at_path (char *path, bool machine_specific, void *data) - struct file_at_path_info *info = (struct file_at_path_info *) data; - size_t path_len = strlen (path); - -- for (auto prefix : { just_machine_prefix, "" }) -+ auto search = [=](size_t len) -> void * - { -- auto len = path_len; -- -- auto prefix_len = strlen(prefix); -- memcpy (path + len, prefix, prefix_len); -- len += prefix_len; -- -- memcpy (path + len, info->name, info->name_len); -+ memcpy (path + len, info->name, info->name_len + 1); - len += info->name_len; - - /* Some systems have a suffix for executable files. -@@ -3120,9 +3114,22 @@ program_at_path (char *path, bool machine_specific, void *data) - path[len] = '\0'; - if (access_check (path, info->mode) == 0) - return path; -+ -+ return NULL; -+ }; -+ -+ /* Additionally search for $target-prog in machine-agnostic dirs, as an -+ additional way to disambiguate targets. Do not do this in machine-specific -+ dirs because so further disambiguation is needed. */ -+ if (!machine_specific) -+ { -+ auto prefix_len = strlen(just_machine_prefix); -+ memcpy (path + path_len, just_machine_prefix, prefix_len); -+ auto res = search(path_len + prefix_len); -+ if (res) return res; - } - -- return NULL; -+ return search(path_len); - } - - /* Specialization of find_a_file for programs that also takes into account --- -2.47.2 - diff --git a/pkgs/development/compilers/gcc/ng/common/gcc/default.nix b/pkgs/development/compilers/gcc/ng/common/gcc/default.nix index 3d8ef0d8300e..fe4688a96beb 100644 --- a/pkgs/development/compilers/gcc/ng/common/gcc/default.nix +++ b/pkgs/development/compilers/gcc/ng/common/gcc/default.nix @@ -5,6 +5,7 @@ release_version, version, monorepoSrc ? null, + fetchpatch, langAda ? false, langC ? true, langCC ? true, @@ -49,9 +50,31 @@ stdenv.mkDerivation (finalAttrs: { ]; patches = [ - (getVersionFile "gcc/0001-find_a_program-First-search-with-machine-prefix.patch") - (getVersionFile "gcc/0002-driver-for_each_pass-Pass-to-callback-whether-dir-is.patch") - (getVersionFile "gcc/0003-find_a_program-Only-search-for-prefixed-paths-in-und.patch") + (fetchpatch { + name = "for_each_path-functional-programming.patch"; + url = "https://github.com/gcc-mirror/gcc/commit/f23bac62f46fc296a4d0526ef54824d406c3756c.diff"; + hash = "sha256-J7SrypmVSbvYUzxWWvK2EwEbRsfGGLg4vNZuLEe6Xe0="; + }) + (fetchpatch { + name = "find_a_program-separate-from-find_a_file.patch"; + url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-1-git@JohnEricson.me/raw"; + hash = "sha256-0gaWaeFZq+a8q7Bcr3eILNjHh1LfzL/Lz4F+W+H6XIU="; + }) + (fetchpatch { + name = "simplify-find_a_program-and-find_a_file.patch"; + url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-2-git@JohnEricson.me/raw"; + hash = "sha256-ojdyszxLGL+njHK4eAaeBkxAhFTDI57j6lGuAf0A+N0="; + }) + (fetchpatch { + name = "for_each_path-pass-machine-specific.patch"; + url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-3-git@JohnEricson.me/raw"; + hash = "sha256-C5jUSyNchmZcE8RTXc2dHfCqNKuBHeiouLruK9UooSM="; + }) + (fetchpatch { + name = "find_a_program-search-with-machine-prefix.patch"; + url = "https://inbox.sourceware.org/gcc-patches/20250822234120.1988059-4-git@JohnEricson.me/raw"; + hash = "sha256-MwcO4OXPlcdaSYivsh5ru+Cfq6qybeAtgCgTEPGYg40="; + }) (getVersionFile "gcc/fix-collect2-paths.diff") ]; diff --git a/pkgs/development/compilers/gcc/ng/common/patches.nix b/pkgs/development/compilers/gcc/ng/common/patches.nix index 81d3be9f68bf..4c1fdd822510 100644 --- a/pkgs/development/compilers/gcc/ng/common/patches.nix +++ b/pkgs/development/compilers/gcc/ng/common/patches.nix @@ -7,31 +7,6 @@ } ]; - # Submitted (001--003): - # - https://gcc.gnu.org/pipermail/gcc-patches/2021-August/577639.html - # - https://gcc.gnu.org/pipermail/gcc-patches/2021-August/577640.html - # - https://gcc.gnu.org/pipermail/gcc-patches/2021-August/577638.html - # - # In Git: https://github.com/Ericson2314/gcc/tree/prog-target-15 - "gcc/0001-find_a_program-First-search-with-machine-prefix.patch" = [ - { - after = "15"; - path = ../15; - } - ]; - "gcc/0002-driver-for_each_pass-Pass-to-callback-whether-dir-is.patch" = [ - { - after = "15"; - path = ../15; - } - ]; - "gcc/0003-find_a_program-Only-search-for-prefixed-paths-in-und.patch" = [ - { - after = "15"; - path = ../15; - } - ]; - # In Git: https://github.com/Ericson2314/gcc/tree/regular-dirs-in-libgcc-15 "libgcc/force-regular-dirs.patch" = [ {