Skip to content

Commit 05d2f2c

Browse files
aykevldeadprogram
authored andcommitted
main: improve support for x86-32 and add tests
To avoid breaking this, make sure we actually test x86-32 (aka i386 aka GOARCH=386) support in CI. Also remove the now-unnecessary binutils-arm-none-eabi package to speed up CI a bit.
1 parent 9a12d12 commit 05d2f2c

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ commands:
2828
qemu-user \
2929
gcc-avr \
3030
avr-libc
31+
sudo apt-get install --no-install-recommends libc6-dev-i386 lib32gcc-8-dev
3132
install-node:
3233
steps:
3334
- run:
@@ -133,14 +134,14 @@ commands:
133134
command: |
134135
sudo apt-get install \
135136
gcc-arm-linux-gnueabihf \
136-
binutils-arm-none-eabi \
137137
libc6-dev-armel-cross \
138138
gcc-aarch64-linux-gnu \
139139
libc6-dev-arm64-cross \
140140
qemu-system-arm \
141141
qemu-user \
142142
gcc-avr \
143143
avr-libc
144+
sudo apt-get install --no-install-recommends libc6-dev-i386 lib32gcc-6-dev
144145
- install-node
145146
- install-wasmtime
146147
- install-xtensa-toolchain:
@@ -194,14 +195,14 @@ commands:
194195
command: |
195196
sudo apt-get install \
196197
gcc-arm-linux-gnueabihf \
197-
binutils-arm-none-eabi \
198198
libc6-dev-armel-cross \
199199
gcc-aarch64-linux-gnu \
200200
libc6-dev-arm64-cross \
201201
qemu-system-arm \
202202
qemu-user \
203203
gcc-avr \
204204
avr-libc
205+
sudo apt-get install --no-install-recommends libc6-dev-i386 lib32gcc-6-dev
205206
- install-node
206207
- install-wasmtime
207208
- install-xtensa-toolchain:

compileopts/target.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func LoadTarget(target string) (*TargetSpec, error) {
215215
}
216216
goarch := map[string]string{ // map from LLVM arch to Go arch
217217
"i386": "386",
218+
"i686": "386",
218219
"x86_64": "amd64",
219220
"aarch64": "arm64",
220221
"armv7": "arm",
@@ -260,9 +261,9 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
260261
spec.GDB = "aarch64-linux-gnu-gdb"
261262
spec.Emulator = []string{"qemu-aarch64", "-L", "/usr/aarch64-linux-gnu"}
262263
}
263-
if goarch == "386" {
264-
spec.CFlags = []string{"-m32"}
265-
spec.LDFlags = []string{"-m32"}
264+
if goarch == "386" && runtime.GOARCH == "amd64" {
265+
spec.CFlags = append(spec.CFlags, "-m32")
266+
spec.LDFlags = append(spec.LDFlags, "-m32")
266267
}
267268
}
268269
return &spec, nil

main_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ func TestCompiler(t *testing.T) {
7878
}
7979

8080
if runtime.GOOS == "linux" {
81+
t.Run("X86Linux", func(t *testing.T) {
82+
runPlatTests("i386--linux-gnu", matches, t)
83+
})
8184
t.Run("ARMLinux", func(t *testing.T) {
8285
runPlatTests("arm--linux-gnueabihf", matches, t)
8386
})
@@ -189,10 +192,11 @@ func runTest(path, target string, t *testing.T) {
189192
t.Fatal("failed to load target spec:", err)
190193
}
191194
if len(spec.Emulator) == 0 {
192-
t.Fatal("no emulator available for target:", target)
195+
cmd = exec.Command(binary)
196+
} else {
197+
args := append(spec.Emulator[1:], binary)
198+
cmd = exec.Command(spec.Emulator[0], args...)
193199
}
194-
args := append(spec.Emulator[1:], binary)
195-
cmd = exec.Command(spec.Emulator[0], args...)
196200
}
197201
stdout := &bytes.Buffer{}
198202
cmd.Stdout = stdout

0 commit comments

Comments
 (0)