Skip to content

Commit 3105e3d

Browse files
xen0ngopherbot
authored andcommitted
cmd/go/internal/work: allow a bunch of loong64-specific flags
Recognize and allow all LoongArch-specific CFLAGS as standardized in the LoongArch Toolchain Conventions v1.1, and implemented in current versions of GCC and Clang, to enable advanced cgo use cases on loong64. These flags are also allowed for linker invocations in case of possible LTO. See: https://github.com/loongson/la-toolchain-conventions/blob/releases/v1.1/LoongArch-toolchain-conventions-EN.adoc#list While at it, also add support for -mtls-dialect as some C programs may benefit performance-wise from the optional TLSDESC usage. This flag is not specific to loong64 though; it is available for amd64, arm, arm64, loong64, riscv64 and x86. Fixes #71597. Change-Id: I35d2507edb71fa324ae429a3ae3c739644a9cac1 Reviewed-on: https://go-review.googlesource.com/c/go/+/647956 LUCI-TryBot-Result: Go LUCI <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: abner chenc <[email protected]> Reviewed-by: Meidan Li <[email protected]>
1 parent 7715ca3 commit 3105e3d

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

src/cmd/go/internal/work/security.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,21 @@ var validCompilerFlags = []*lazyregexp.Regexp{
9696
re(`-g([^@\-].*)?`),
9797
re(`-m32`),
9898
re(`-m64`),
99-
re(`-m(abi|arch|cpu|fpu|tune)=([^@\-].*)`),
99+
re(`-m(abi|arch|cpu|fpu|simd|tls-dialect|tune)=([^@\-].*)`),
100100
re(`-m(no-)?v?aes`),
101101
re(`-marm`),
102102
re(`-m(no-)?avx[0-9a-z]*`),
103103
re(`-mcmodel=[0-9a-z-]+`),
104104
re(`-mfloat-abi=([^@\-].*)`),
105+
re(`-m(soft|single|double)-float`),
105106
re(`-mfpmath=[0-9a-z,+]*`),
106107
re(`-m(no-)?avx[0-9a-z.]*`),
107108
re(`-m(no-)?ms-bitfields`),
108109
re(`-m(no-)?stack-(.+)`),
109110
re(`-mmacosx-(.+)`),
111+
re(`-m(no-)?relax`),
112+
re(`-m(no-)?strict-align`),
113+
re(`-m(no-)?(lsx|lasx|frecipe|div32|lam-bh|lamcas|ld-seq-sa)`),
110114
re(`-mios-simulator-version-min=(.+)`),
111115
re(`-miphoneos-version-min=(.+)`),
112116
re(`-mlarge-data-threshold=[0-9]+`),
@@ -166,8 +170,13 @@ var validLinkerFlags = []*lazyregexp.Regexp{
166170
re(`-flat_namespace`),
167171
re(`-g([^@\-].*)?`),
168172
re(`-headerpad_max_install_names`),
169-
re(`-m(abi|arch|cpu|fpu|tune)=([^@\-].*)`),
173+
re(`-m(abi|arch|cpu|fpu|simd|tls-dialect|tune)=([^@\-].*)`),
174+
re(`-mcmodel=[0-9a-z-]+`),
170175
re(`-mfloat-abi=([^@\-].*)`),
176+
re(`-m(soft|single|double)-float`),
177+
re(`-m(no-)?relax`),
178+
re(`-m(no-)?strict-align`),
179+
re(`-m(no-)?(lsx|lasx|frecipe|div32|lam-bh|lamcas|ld-seq-sa)`),
171180
re(`-mmacosx-(.+)`),
172181
re(`-mios-simulator-version-min=(.+)`),
173182
re(`-miphoneos-version-min=(.+)`),

src/cmd/go/internal/work/security_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,35 @@ var goodCompilerFlags = [][]string{
5050
{"-ftls-model=local-dynamic"},
5151
{"-g"},
5252
{"-ggdb"},
53+
{"-mabi=lp64d"},
5354
{"-march=souza"},
5455
{"-mcmodel=medium"},
5556
{"-mcpu=123"},
5657
{"-mfpu=123"},
58+
{"-mtls-dialect=gnu"},
59+
{"-mtls-dialect=gnu2"},
60+
{"-mtls-dialect=trad"},
61+
{"-mtls-dialect=desc"},
62+
{"-mtls-dialect=xyz"},
63+
{"-msimd=lasx"},
64+
{"-msimd=xyz"},
65+
{"-mdouble-float"},
66+
{"-mrelax"},
67+
{"-mstrict-align"},
68+
{"-mlsx"},
69+
{"-mlasx"},
70+
{"-mfrecipe"},
71+
{"-mlam-bh"},
72+
{"-mlamcas"},
73+
{"-mld-seq-sa"},
74+
{"-mno-relax"},
75+
{"-mno-strict-align"},
76+
{"-mno-lsx"},
77+
{"-mno-lasx"},
78+
{"-mno-frecipe"},
79+
{"-mno-lam-bh"},
80+
{"-mno-lamcas"},
81+
{"-mno-ld-seq-sa"},
5782
{"-mlarge-data-threshold=16"},
5883
{"-mtune=happybirthday"},
5984
{"-mstack-overflow"},
@@ -96,7 +121,13 @@ var badCompilerFlags = [][]string{
96121
{"-march=@dawn"},
97122
{"-march=-dawn"},
98123
{"-mcmodel=@model"},
124+
{"-mfpu=@0"},
125+
{"-mfpu=-0"},
99126
{"-mlarge-data-threshold=@12"},
127+
{"-mtls-dialect=@gnu"},
128+
{"-mtls-dialect=-gnu"},
129+
{"-msimd=@none"},
130+
{"-msimd=-none"},
100131
{"-std=@c99"},
101132
{"-std=-c99"},
102133
{"-x@c"},

0 commit comments

Comments
 (0)