Skip to content

Commit b83f032

Browse files
author
Adam Joseph
committed
gcc/11: apply upstream fix 103910 so openjdk builds
Our openjdk derivations fail to build with `-march=opteron` (via either `NIX_CFLAGS_COMPILE` or `hostPlatform.gcc.arch`). This was fixed upstream in gcc12 but not carried back to gcc11: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d243f4009d8071b734df16cd70f4c5d09a373769 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103910 Since gcc11 is still nixpkgs' primary compiler, this PR cherry-picks the fix out of gcc12. Unfortunately since `-march=` can be added after the `gcc11` derivation is built we can't apply this patch conditionally (which we don't usually do anyways).
1 parent d381e51 commit b83f032

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

pkgs/development/compilers/gcc/11/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ let majorVersion = "11";
8282
++ optional (stdenv.isDarwin && targetPlatform.isAvr) ./avr-gcc-11.3-darwin.patch
8383

8484
# Obtain latest patch with ../update-mcfgthread-patches.sh
85-
++ optional (!crossStageStatic && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch;
85+
++ optional (!crossStageStatic && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch
86+
87+
# openjdk build fails without this on -march=opteron; is upstream in gcc12
88+
++ [ ./gcc-issue-103910.patch ];
8689

8790
/* Cross-gcc settings (build == host != target) */
8891
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From d243f4009d8071b734df16cd70f4c5d09a373769 Mon Sep 17 00:00:00 2001
2+
From: Andrew Pinski <apinski@marvell.com>
3+
Date: Wed, 5 Jan 2022 22:00:07 +0000
4+
Subject: [PATCH] Fix target/103910: missing GTY on x86_mfence causing PCH
5+
usage to ICE
6+
7+
With -O3 -march=opteron, a mfence builtin is added after the loop
8+
to say the nontemporal stores are no longer needed. This all good
9+
without precompiled headers as the function decl that is referneced
10+
by x86_mfence is referenced in another variable but with precompiled
11+
headers, x86_mfence is all messed up and the decl was GC'ed away.
12+
This fixes the problem by marking x86_mfence as GTY to save/restore
13+
during precompiled headers just like most other variables in
14+
the header file.
15+
16+
Committed as obvious after a bootstrap/test on x86_64-linux-gnu.
17+
18+
gcc/ChangeLog:
19+
20+
PR target/103910
21+
* config/i386/i386.h (x86_mfence): Mark with GTY.
22+
---
23+
gcc/config/i386/i386.h | 2 +-
24+
1 file changed, 1 insertion(+), 1 deletion(-)
25+
26+
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
27+
index f027608eefa..3ac0f698ae2 100644
28+
--- a/gcc/config/i386/i386.h
29+
+++ b/gcc/config/i386/i386.h
30+
@@ -486,7 +486,7 @@ extern unsigned char ix86_prefetch_sse;
31+
32+
/* Fence to use after loop using storent. */
33+
34+
-extern tree x86_mfence;
35+
+extern GTY(()) tree x86_mfence;
36+
#define FENCE_FOLLOWING_MOVNT x86_mfence
37+
38+
/* Once GDB has been enhanced to deal with functions without frame
39+
--
40+
2.31.1
41+

0 commit comments

Comments
 (0)