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.
Этот коммит содержится в:
Ayke van Laethem 2020-09-23 17:26:43 +02:00 коммит произвёл Ron Evans
родитель 9a12d129ab
коммит 05d2f2c412
3 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -28,6 +28,7 @@ commands:
qemu-user \ qemu-user \
gcc-avr \ gcc-avr \
avr-libc avr-libc
sudo apt-get install --no-install-recommends libc6-dev-i386 lib32gcc-8-dev
install-node: install-node:
steps: steps:
- run: - run:
@ -133,7 +134,6 @@ commands:
command: | command: |
sudo apt-get install \ sudo apt-get install \
gcc-arm-linux-gnueabihf \ gcc-arm-linux-gnueabihf \
binutils-arm-none-eabi \
libc6-dev-armel-cross \ libc6-dev-armel-cross \
gcc-aarch64-linux-gnu \ gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \ libc6-dev-arm64-cross \
@ -141,6 +141,7 @@ commands:
qemu-user \ qemu-user \
gcc-avr \ gcc-avr \
avr-libc avr-libc
sudo apt-get install --no-install-recommends libc6-dev-i386 lib32gcc-6-dev
- install-node - install-node
- install-wasmtime - install-wasmtime
- install-xtensa-toolchain: - install-xtensa-toolchain:
@ -194,7 +195,6 @@ commands:
command: | command: |
sudo apt-get install \ sudo apt-get install \
gcc-arm-linux-gnueabihf \ gcc-arm-linux-gnueabihf \
binutils-arm-none-eabi \
libc6-dev-armel-cross \ libc6-dev-armel-cross \
gcc-aarch64-linux-gnu \ gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \ libc6-dev-arm64-cross \
@ -202,6 +202,7 @@ commands:
qemu-user \ qemu-user \
gcc-avr \ gcc-avr \
avr-libc avr-libc
sudo apt-get install --no-install-recommends libc6-dev-i386 lib32gcc-6-dev
- install-node - install-node
- install-wasmtime - install-wasmtime
- install-xtensa-toolchain: - install-xtensa-toolchain:

Просмотреть файл

@ -215,6 +215,7 @@ func LoadTarget(target string) (*TargetSpec, error) {
} }
goarch := map[string]string{ // map from LLVM arch to Go arch goarch := map[string]string{ // map from LLVM arch to Go arch
"i386": "386", "i386": "386",
"i686": "386",
"x86_64": "amd64", "x86_64": "amd64",
"aarch64": "arm64", "aarch64": "arm64",
"armv7": "arm", "armv7": "arm",
@ -260,9 +261,9 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
spec.GDB = "aarch64-linux-gnu-gdb" spec.GDB = "aarch64-linux-gnu-gdb"
spec.Emulator = []string{"qemu-aarch64", "-L", "/usr/aarch64-linux-gnu"} spec.Emulator = []string{"qemu-aarch64", "-L", "/usr/aarch64-linux-gnu"}
} }
if goarch == "386" { if goarch == "386" && runtime.GOARCH == "amd64" {
spec.CFlags = []string{"-m32"} spec.CFlags = append(spec.CFlags, "-m32")
spec.LDFlags = []string{"-m32"} spec.LDFlags = append(spec.LDFlags, "-m32")
} }
} }
return &spec, nil return &spec, nil

Просмотреть файл

@ -78,6 +78,9 @@ func TestCompiler(t *testing.T) {
} }
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
t.Run("X86Linux", func(t *testing.T) {
runPlatTests("i386--linux-gnu", matches, t)
})
t.Run("ARMLinux", func(t *testing.T) { t.Run("ARMLinux", func(t *testing.T) {
runPlatTests("arm--linux-gnueabihf", matches, t) runPlatTests("arm--linux-gnueabihf", matches, t)
}) })
@ -189,11 +192,12 @@ func runTest(path, target string, t *testing.T) {
t.Fatal("failed to load target spec:", err) t.Fatal("failed to load target spec:", err)
} }
if len(spec.Emulator) == 0 { if len(spec.Emulator) == 0 {
t.Fatal("no emulator available for target:", target) cmd = exec.Command(binary)
} } else {
args := append(spec.Emulator[1:], binary) args := append(spec.Emulator[1:], binary)
cmd = exec.Command(spec.Emulator[0], args...) cmd = exec.Command(spec.Emulator[0], args...)
} }
}
stdout := &bytes.Buffer{} stdout := &bytes.Buffer{}
cmd.Stdout = stdout cmd.Stdout = stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr