Skip to content

crash: Cross-compiling go-sqlite3 to openbsd/arm64 #68616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dekimsey opened this issue Oct 9, 2023 · 5 comments
Open

crash: Cross-compiling go-sqlite3 to openbsd/arm64 #68616

dekimsey opened this issue Oct 9, 2023 · 5 comments
Labels
backend:AArch64 crash Prefer [crash-on-valid] or [crash-on-invalid] platform:openbsd

Comments

@dekimsey
Copy link

dekimsey commented Oct 9, 2023

Summary

This build attempts to cross-compile the go-sqlite3's _example/simple Go project from a linux/amd64 host to an openbsd/arm64 target. However, clang appears to crash on the generated generated _cgo-exports.c at Running pass 'Post-RA pseudo instruction expansion pass' on function '@callbackTrampoline'.

It wasn't clear to me if this is a Go issue or an LLVM issue, but I figured I'd start here since the toolchain asked :). Thank you!

Versions:

  • Ubuntu 22.04
  • clang (14.0.0-1ubuntu1.1)
  • OpenBSD 7.2 target sysroot
  • go-sqlite (v1.14.17)
  • Go 1.21.1 (patched to pass -Wl,--no-pie flag correctly)

Build

Environment:

CC=clang-14
CGO_CFLAGS=-O2 -g -v -target aarch64-openbsd --sysroot=/opt/openbsd.arm64
CGO_ENABLED=1
CGO_LDFLAGS=-v -target aarch64-openbsd -fuse-ld=lld --sysroot=/opt/openbsd.arm64
GOOS=openbsd
GOARCH=arm64

Build Log:

go build -a -v .

root@2158d02123a7:/src/src/go-sqlite3/_example/simple# go build -a -v .
internal/unsafeheader
internal/coverage/rtcov
internal/goarch
internal/cpu
internal/godebugs
internal/abi
internal/goexperiment
internal/goos
runtime/internal/math
runtime/internal/sys
internal/race
internal/bytealg
runtime/internal/atomic
sync/atomic
unicode/utf8
unicode
internal/itoa
math/bits
crypto/internal/alias
crypto/subtle
math
crypto/internal/boring/sig
log/internal
runtime
internal/reflectlite
sync
internal/testlog
runtime/cgo
errors
sort
io
internal/oserror
syscall
strconv
bytes
internal/safefilepath
path
hash
strings
reflect
crypto
internal/syscall/unix
time
internal/syscall/execenv
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_export.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-build408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x001.o -x c _cgo_export.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cgo.cgo2.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-build408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x002.o -x c cgo.cgo2.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_context.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x003.o -x c gcc_context.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_libinit.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x004.o -x c gcc_libinit.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_openbsd_arm64.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x005.o -x c gcc_openbsd_arm64.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_setenv.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x006.o -x c gcc_setenv.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_stack_unix.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x007.o -x c gcc_stack_unix.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_util.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x008.o -x c gcc_util.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_arm64.S -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/gcc_arm64-546e6b.s -x assembler-with-cpp gcc_arm64.S
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
 "/usr/lib/llvm-14/bin/clang" -cc1as -triple aarch64-unknown-openbsd -filetype obj -main-file-name gcc_arm64.S -target-cpu generic -target-feature +neon -target-feature +v8a -target-feature +strict-align -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -dwarf-debug-producer "Ubuntu clang version 14.0.0-1ubuntu1.1" -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -debug-info-kind=constructor -dwarf-version=2 -mrelocation-model pic --mrelax-relocations -object-file-name=/tmp/go-build408674212/b061/_x009.o -o $WORK/b061/_x009.o /tmp/gcc_arm64-546e6b.s
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_main.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-build408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_cgo_main.o -x c _cgo_main.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
context
internal/poll
io/fs
os
encoding/binary
internal/fmtsort
crypto/cipher
fmt
crypto/internal/boring
crypto/sha512
crypto/sha256
crypto/sha1
net/url
log
database/sql/driver
database/sql
github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_export.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b047 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I ../.. -I $WORK/b047/ -D SQLITE_ENABLE_RTREE -D SQLITE_THREADSAFE=1 -D HAVE_USLEEP=1 -D SQLITE_ENABLE_FTS3 -D SQLITE_ENABLE_FTS3_PARENTHESIS -D SQLITE_TRACE_SIZE_LIMIT=15 -D SQLITE_OMIT_DEPRECATED -D SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -D SQLITE_ENABLE_UPDATE_DELETE_LIMIT -I /usr/local/include -I ../.. -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wno-deprecated-declarations -std=gnu99 -fdebug-compilation-dir=/tmp/go-build408674212/b047 -ferror-limiencoding/binary
 /usr/local/go.nopie/src/runtime/cgo                                                                                                                                                              [94/1851]
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_s
tack_unix.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -
Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-k
ind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/
cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-
dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x007.o -x c
gcc_stack_unix.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu                                                                                                                        #include "..." search starts here:                                                                                                                                                                         #include <...> search starts here:                                                                                                                                                                          /usr/local/go.nopie/src/runtime/cgo                                                                                                                                                                        $WORK/b061                                                                                                                                                                                                 /usr/lib/llvm-14/lib/clang/14.0.0/include                                                                                                                                                                  /opt/openbsd.arm64/usr/include                                                                                                                                                                            End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_u
til.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunali
gned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=co
nstructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I
 $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/u
sr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x008.o -x c gcc_ut
il.c                                                                                                                                                                                                       clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu                                                                                                                        #include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_arm64.S -mrelocation-model pi
c -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature
 +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation
-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm
-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-c
har -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/gcc_arm64-546e6b.s -x assembler-with-cpp gcc_arm64.S
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu                                                                                                                        #include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
 "/usr/lib/llvm-14/bin/clang" -cc1as -triple aarch64-unknown-openbsd -filetype obj -main-file-name gcc_arm64.S -target-cpu generic -target-feature +neon -target-feature +v8a -target-feature +strict-align
 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -dwarf-debug-producer "Ubuntu clang version 14.0.0-1ubuntu1.1" -I /usr/local/go.nopie/sr
c/runtime/cgo -I $WORK/b061/ -debug-info-kind=constructor -dwarf-version=2 -mrelocation-model pic --mrelax-relocations -object-file-name=/tmp/go-build408674212/b061/_x009.o -o $WORK/b061/_x009.o /tmp/gcc
_arm64-546e6b.s
# runtime/cgo                                                                                                                                                                                              Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_
main.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunal
igned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=c
onstructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/
b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-b
uild408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_cgo_main.o -x c _cgo_main.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
context
internal/poll
io/fs
os
encoding/binary
internal/fmtsort
crypto/cipher
fmt
crypto/internal/boring
crypto/sha512
crypto/sha256
crypto/sha1
net/url
log
database/sql/driver
database/sql
github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_export.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b047 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I ../.. -I $WORK/b047/ -D SQLITE_ENABLE_RTREE -D SQLITE_THREADSAFE=1 -D HAVE_USLEEP=1 -D SQLITE_ENABLE_FTS3 -D SQLITE_ENABLE_FTS3_PARENTHESIS -D SQLITE_TRACE_SIZE_LIMIT=15 -D SQLITE_OMIT_DEPRECATED -D SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -D SQLITE_ENABLE_UPDATE_DELETE_LIMIT -I /usr/local/include -I ../.. -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wno-deprecated-declarations -std=gnu99 -fdebug-compilation-dir=/tmp/go-build408674212/b047 -ferror-limit 19 -pthread -stack-protector 2 -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b047/_x001.o -x c _cgo_export.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
ignoring duplicate directory "/src/src/go-sqlite3"
#include "..." search starts here:
#include <...> search starts here:
 ../..
 $WORK/b047
 /usr/local/include
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/clang-14 -I ../.. -fPIC -pthread -fmessage-length=0 -I $WORK/b047/ -O2 -g -v -target aarch64-openbsd --sysroot=/opt/openbsd.arm64 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE=1 -DHAVE_USLEEP=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_TRACE_SIZE_LIMIT=15 -DSQLITE_OMIT_DEPRECATED -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -Wno-deprecated-declarations -I/usr/local/include -I/src/src/go-sql
ite3 -o $WORK/b047/_x001.o -c _cgo_export.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '_cgo_export.c'.
4.      Running pass 'Post-RA pseudo instruction expansion pass' on function '@callbackTrampoline'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x31)[0x7fc8ccd24d01]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x7fc8ccd22a3e]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15CleanupOnSignalEm+0xfb)[0x7fc8ccd240ab]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0xd6bdff)[0x7fc8ccc50dff]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fc8cb9cc520]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0x29d2880)[0x7fc8ce8b7880]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0x10b81bb)[0x7fc8ccf9d1bb]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0x12e)[0x7fc8cd0ab28e]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x3a0)[0x7fc8cce5f390]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x33)[0x7fc8cce66983]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x946)[0x7fc8cce5ff36]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsEN4llvm9StringRefEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISK_EE+0xbc1)[0x7fc8d400e201]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x1b7c855)[0x7fc8d4333855]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang8ParseASTERNS_4SemaEbb+0x244)[0x7fc8d31bb824]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang13CodeGenAction13ExecuteActionEv+0xb1)[0x7fc8d432fb71]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang14FrontendAction7ExecuteEv+0x67)[0x7fc8d4ccbb57]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x336)[0x7fc8d4c233a6]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x29b)[0x7fc8d4d4545b]
/usr/bin/clang-14(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x99b)[0x41328b]
/usr/bin/clang-14[0x4114bc]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x20eaed2)[0x7fc8d48a1ed2]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xdd)[0x7fc8ccc50b6d]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x140)[0x7fc8d48a19c0]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x3f3)[0x7fc8d486c183]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x8a)[0x7fc8d486c40a]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x1a7)[0x7fc8d4886507]
/usr/bin/clang-14(main+0x2816)[0x410f26]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7fc8cb9b3d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7fc8cb9b3e40]
/usr/bin/clang-14(_start+0x25)[0x40e3b5]
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/_cgo_export-fa0dd7.c
clang: note: diagnostic msg: /tmp/_cgo_export-fa0dd7.sh
clang: note: diagnostic msg:

********************

Reproduction Steps:

These instructions are written using the below Dockerfile to make reproduction easier. Please let me know if more information is needed.

$ podman build -f ~/Dockerfile --tag crash
$ podman run --rm -it crash
# pushd go-sqlite3-1.14.17/_example/simple/
# go build -a -v .
Dockerfile

FROM ubuntu:22.04 as base
RUN apt-get update \
        && apt-get install -y curl
WORKDIR /src

FROM base as go-patch

ARG GO_VERSION=1.21.1
RUN curl -LO https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
    && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
    && rm -vf go${GO_VERSION}.linux-amd64.tar.gz \
    && mkdir -p /src

RUN apt-get install -y git gcc &&\
    git clone --single-branch --depth=1 --branch test-nopie-support-in-clang https://github.com/dekimsey/go.git /usr/local/go.nopie &&\
    cd /usr/local/go.nopie/src >/dev/null &&\
    PATH="$PATH:/usr/local/go/bin" ./make.bash

FROM base
ARG OPENBSD_RELEASE=7.2
ARG OPENBSD_RELEASE_SUFFIX=72

COPY --from=go-patch /usr/local/go.nopie /usr/local/go.nopie
ENV PATH="${PATH}:/usr/local/go.nopie/bin"

RUN apt-get install -y clang-14 lld-14

ENV openbsd_root_arm64=/opt/openbsd.arm64
RUN mkdir -p $openbsd_root_arm64 &&\
    curl -sSfLO https://cdn.openbsd.org/pub/OpenBSD/${OPENBSD_RELEASE}/arm64/base${OPENBSD_RELEASE_SUFFIX}.tgz &&\
    curl -sSfLO https://cdn.openbsd.org/pub/OpenBSD/${OPENBSD_RELEASE}/arm64/comp${OPENBSD_RELEASE_SUFFIX}.tgz &&\
    for f in *.tgz ; do echo "### $f ###" > $openbsd_root_arm64/$f.index; tar -tvf $f > $openbsd_root_arm64/$f.index ; done &&\
    tar -C ${openbsd_root_arm64} -xvf base${OPENBSD_RELEASE_SUFFIX}.tgz ./usr/lib ./usr/include &&\
    tar -C ${openbsd_root_arm64} -xvf comp${OPENBSD_RELEASE_SUFFIX}.tgz ./usr/lib ./usr/include &&\
    rm -vf *.tgz

WORKDIR /src

RUN curl -sSfLO https://github.com/mattn/go-sqlite3/archive/refs/tags/v1.14.17.tar.gz &&\
    tar -xf v1.14.17.tar.gz

ENV GOOS=openbsd \
    GOARCH=goarm \
    CGO_ENABLED=1 \
    CC=clang-14 \
    CGO_CFLAGS="-O2 -g -v -target aarch64-openbsd --sysroot=$openbsd_root_arm64" \
    CGO_LDFLAGS="-v -target aarch64-openbsd -fuse-ld=lld --sysroot=$openbsd_root_arm64"

Diagnostics:

@Endilll Endilll added backend:AArch64 platform:openbsd crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Oct 10, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 10, 2023

@llvm/issue-subscribers-backend-aarch64

Author: Daniel Kimsey (dekimsey)

# Summary

This build attempts to cross-compile the go-sqlite3's _example/simple Go project from a linux/amd64 host to an openbsd/arm64 target. However, clang appears to crash on the generated generated _cgo-exports.c at Running pass 'Post-RA pseudo instruction expansion pass' on function '@<!-- -->callbackTrampoline'.

It wasn't clear to me if this is a Go issue or an LLVM issue, but I figured I'd start here since the toolchain asked :). Thank you!

Versions:

  • Ubuntu 22.04
  • clang (14.0.0-1ubuntu1.1)
  • OpenBSD 7.2 target sysroot
  • go-sqlite (v1.14.17)
  • Go 1.21.1 (patched to pass -Wl,--no-pie flag correctly)

Build

Environment:

CC=clang-14
CGO_CFLAGS=-O2 -g -v -target aarch64-openbsd --sysroot=/opt/openbsd.arm64
CGO_ENABLED=1
CGO_LDFLAGS=-v -target aarch64-openbsd -fuse-ld=lld --sysroot=/opt/openbsd.arm64
GOOS=openbsd
GOARCH=arm64

Build Log:
<details><summary>go build -a -v .</summary>
<p>

root@<!-- -->2158d02123a7:/src/src/go-sqlite3/_example/simple# go build -a -v .
internal/unsafeheader
internal/coverage/rtcov
internal/goarch
internal/cpu
internal/godebugs
internal/abi
internal/goexperiment
internal/goos
runtime/internal/math
runtime/internal/sys
internal/race
internal/bytealg
runtime/internal/atomic
sync/atomic
unicode/utf8
unicode
internal/itoa
math/bits
crypto/internal/alias
crypto/subtle
math
crypto/internal/boring/sig
log/internal
runtime
internal/reflectlite
sync
internal/testlog
runtime/cgo
errors
sort
io
internal/oserror
syscall
strconv
bytes
internal/safefilepath
path
hash
strings
reflect
crypto
internal/syscall/unix
time
internal/syscall/execenv
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_export.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-build408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x001.o -x c _cgo_export.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cgo.cgo2.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-build408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x002.o -x c cgo.cgo2.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_context.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x003.o -x c gcc_context.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_libinit.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x004.o -x c gcc_libinit.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_openbsd_arm64.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x005.o -x c gcc_openbsd_arm64.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_setenv.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x006.o -x c gcc_setenv.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_stack_unix.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x007.o -x c gcc_stack_unix.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_util.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x008.o -x c gcc_util.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_arm64.S -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/gcc_arm64-546e6b.s -x assembler-with-cpp gcc_arm64.S
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
 "/usr/lib/llvm-14/bin/clang" -cc1as -triple aarch64-unknown-openbsd -filetype obj -main-file-name gcc_arm64.S -target-cpu generic -target-feature +neon -target-feature +v8a -target-feature +strict-align -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -dwarf-debug-producer "Ubuntu clang version 14.0.0-1ubuntu1.1" -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -debug-info-kind=constructor -dwarf-version=2 -mrelocation-model pic --mrelax-relocations -object-file-name=/tmp/go-build408674212/b061/_x009.o -o $WORK/b061/_x009.o /tmp/gcc_arm64-546e6b.s
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_main.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-build408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_cgo_main.o -x c _cgo_main.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
context
internal/poll
io/fs
os
encoding/binary
internal/fmtsort
crypto/cipher
fmt
crypto/internal/boring
crypto/sha512
crypto/sha256
crypto/sha1
net/url
log
database/sql/driver
database/sql
github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_export.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b047 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I ../.. -I $WORK/b047/ -D SQLITE_ENABLE_RTREE -D SQLITE_THREADSAFE=1 -D HAVE_USLEEP=1 -D SQLITE_ENABLE_FTS3 -D SQLITE_ENABLE_FTS3_PARENTHESIS -D SQLITE_TRACE_SIZE_LIMIT=15 -D SQLITE_OMIT_DEPRECATED -D SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -D SQLITE_ENABLE_UPDATE_DELETE_LIMIT -I /usr/local/include -I ../.. -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wno-deprecated-declarations -std=gnu99 -fdebug-compilation-dir=/tmp/go-build408674212/b047 -ferror-limiencoding/binary
 /usr/local/go.nopie/src/runtime/cgo                                                                                                                                                              [94/1851]
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_s
tack_unix.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -
Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-k
ind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/
cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-
dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x007.o -x c
gcc_stack_unix.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu                                                                                                                        #include "..." search starts here:                                                                                                                                                                         #include &lt;...&gt; search starts here:                                                                                                                                                                          /usr/local/go.nopie/src/runtime/cgo                                                                                                                                                                        $WORK/b061                                                                                                                                                                                                 /usr/lib/llvm-14/lib/clang/14.0.0/include                                                                                                                                                                  /opt/openbsd.arm64/usr/include                                                                                                                                                                            End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_u
til.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunali
gned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=co
nstructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I
 $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/u
sr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_x008.o -x c gcc_ut
il.c                                                                                                                                                                                                       clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu                                                                                                                        #include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
# runtime/cgo
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gcc_arm64.S -mrelocation-model pi
c -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature
 +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation
-dir=/usr/local/go.nopie/src/runtime/cgo -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm
-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -ferror-limit 19 -pthread -fno-signed-c
har -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/gcc_arm64-546e6b.s -x assembler-with-cpp gcc_arm64.S
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu                                                                                                                        #include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
 "/usr/lib/llvm-14/bin/clang" -cc1as -triple aarch64-unknown-openbsd -filetype obj -main-file-name gcc_arm64.S -target-cpu generic -target-feature +neon -target-feature +v8a -target-feature +strict-align
 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/b061/ -fdebug-compilation-dir=/usr/local/go.nopie/src/runtime/cgo -dwarf-debug-producer "Ubuntu clang version 14.0.0-1ubuntu1.1" -I /usr/local/go.nopie/sr
c/runtime/cgo -I $WORK/b061/ -debug-info-kind=constructor -dwarf-version=2 -mrelocation-model pic --mrelax-relocations -object-file-name=/tmp/go-build408674212/b061/_x009.o -o $WORK/b061/_x009.o /tmp/gcc
_arm64-546e6b.s
# runtime/cgo                                                                                                                                                                                              Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_
main.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunal
igned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=c
onstructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b061 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/local/go.nopie/src/runtime/cgo -I $WORK/
b061/ -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wall -Werror -fdebug-compilation-dir=/tmp/go-b
uild408674212/b061 -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b061/_cgo_main.o -x c _cgo_main.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/local/go.nopie/src/runtime/cgo
 $WORK/b061
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
context
internal/poll
io/fs
os
encoding/binary
internal/fmtsort
crypto/cipher
fmt
crypto/internal/boring
crypto/sha512
crypto/sha256
crypto/sha1
net/url
log
database/sql/driver
database/sql
github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple aarch64-unknown-openbsd -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name _cgo_export.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -Wunaligned-access -target-feature +neon -target-feature +v8a -target-feature +strict-align -target-abi aapcs -fallow-half-arguments-and-returns -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp/go-build408674212/b047 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I ../.. -I $WORK/b047/ -D SQLITE_ENABLE_RTREE -D SQLITE_THREADSAFE=1 -D HAVE_USLEEP=1 -D SQLITE_ENABLE_FTS3 -D SQLITE_ENABLE_FTS3_PARENTHESIS -D SQLITE_TRACE_SIZE_LIMIT=15 -D SQLITE_OMIT_DEPRECATED -D SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -D SQLITE_ENABLE_UPDATE_DELETE_LIMIT -I /usr/local/include -I ../.. -isysroot /opt/openbsd.arm64 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-externc-isystem /opt/openbsd.arm64/usr/include -O2 -Wno-deprecated-declarations -std=gnu99 -fdebug-compilation-dir=/tmp/go-build408674212/b047 -ferror-limit 19 -pthread -stack-protector 2 -fno-signed-char -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o $WORK/b047/_x001.o -x c _cgo_export.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
ignoring duplicate directory "/src/src/go-sqlite3"
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 ../..
 $WORK/b047
 /usr/local/include
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /opt/openbsd.arm64/usr/include
End of search list.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/clang-14 -I ../.. -fPIC -pthread -fmessage-length=0 -I $WORK/b047/ -O2 -g -v -target aarch64-openbsd --sysroot=/opt/openbsd.arm64 -std=gnu99 -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE=1 -DHAVE_USLEEP=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_TRACE_SIZE_LIMIT=15 -DSQLITE_OMIT_DEPRECATED -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -Wno-deprecated-declarations -I/usr/local/include -I/src/src/go-sql
ite3 -o $WORK/b047/_x001.o -c _cgo_export.c
1.      &lt;eof&gt; parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '_cgo_export.c'.
4.      Running pass 'Post-RA pseudo instruction expansion pass' on function '@<!-- -->callbackTrampoline'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x31)[0x7fc8ccd24d01]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x7fc8ccd22a3e]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15CleanupOnSignalEm+0xfb)[0x7fc8ccd240ab]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0xd6bdff)[0x7fc8ccc50dff]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fc8cb9cc520]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0x29d2880)[0x7fc8ce8b7880]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0x10b81bb)[0x7fc8ccf9d1bb]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0x12e)[0x7fc8cd0ab28e]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x3a0)[0x7fc8cce5f390]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x33)[0x7fc8cce66983]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x946)[0x7fc8cce5ff36]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsEN4llvm9StringRefEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISK_EE+0xbc1)[0x7fc8d400e201]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x1b7c855)[0x7fc8d4333855]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang8ParseASTERNS_4SemaEbb+0x244)[0x7fc8d31bb824]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang13CodeGenAction13ExecuteActionEv+0xb1)[0x7fc8d432fb71]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang14FrontendAction7ExecuteEv+0x67)[0x7fc8d4ccbb57]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x336)[0x7fc8d4c233a6]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x29b)[0x7fc8d4d4545b]
/usr/bin/clang-14(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x99b)[0x41328b]
/usr/bin/clang-14[0x4114bc]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x20eaed2)[0x7fc8d48a1ed2]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xdd)[0x7fc8ccc50b6d]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x140)[0x7fc8d48a19c0]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x3f3)[0x7fc8d486c183]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x8a)[0x7fc8d486c40a]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x1a7)[0x7fc8d4886507]
/usr/bin/clang-14(main+0x2816)[0x410f26]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7fc8cb9b3d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7fc8cb9b3e40]
/usr/bin/clang-14(_start+0x25)[0x40e3b5]
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: aarch64-unknown-openbsd
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/_cgo_export-fa0dd7.c
clang: note: diagnostic msg: /tmp/_cgo_export-fa0dd7.sh
clang: note: diagnostic msg:

********************

</p>
</details>

Reproduction Steps:

These instructions are written using the below Dockerfile to make reproduction easier. Please let me know if more information is needed.

$ podman build -f ~/Dockerfile --tag crash
$ podman run --rm -it crash
# pushd go-sqlite3-1.14.17/_example/simple/
# go build -a -v .

<details><summary>Dockerfile</summary>
<p>

FROM ubuntu:22.04 as base
RUN apt-get update \
        &amp;&amp; apt-get install -y curl
WORKDIR /src

FROM base as go-patch

ARG GO_VERSION=1.21.1
RUN curl -LO https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
    &amp;&amp; tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
    &amp;&amp; rm -vf go${GO_VERSION}.linux-amd64.tar.gz \
    &amp;&amp; mkdir -p /src

RUN apt-get install -y git gcc &amp;&amp;\
    git clone --single-branch --depth=1 --branch test-nopie-support-in-clang https://github.com/dekimsey/go.git /usr/local/go.nopie &amp;&amp;\
    cd /usr/local/go.nopie/src &gt;/dev/null &amp;&amp;\
    PATH="$PATH:/usr/local/go/bin" ./make.bash

FROM base
ARG OPENBSD_RELEASE=7.2
ARG OPENBSD_RELEASE_SUFFIX=72

COPY --from=go-patch /usr/local/go.nopie /usr/local/go.nopie
ENV PATH="${PATH}:/usr/local/go.nopie/bin"

RUN apt-get install -y clang-14 lld-14

ENV openbsd_root_arm64=/opt/openbsd.arm64
RUN mkdir -p $openbsd_root_arm64 &amp;&amp;\
    curl -sSfLO https://cdn.openbsd.org/pub/OpenBSD/${OPENBSD_RELEASE}/arm64/base${OPENBSD_RELEASE_SUFFIX}.tgz &amp;&amp;\
    curl -sSfLO https://cdn.openbsd.org/pub/OpenBSD/${OPENBSD_RELEASE}/arm64/comp${OPENBSD_RELEASE_SUFFIX}.tgz &amp;&amp;\
    for f in *.tgz ; do echo "### $f ###" &gt; $openbsd_root_arm64/$f.index; tar -tvf $f &gt; $openbsd_root_arm64/$f.index ; done &amp;&amp;\
    tar -C ${openbsd_root_arm64} -xvf base${OPENBSD_RELEASE_SUFFIX}.tgz ./usr/lib ./usr/include &amp;&amp;\
    tar -C ${openbsd_root_arm64} -xvf comp${OPENBSD_RELEASE_SUFFIX}.tgz ./usr/lib ./usr/include &amp;&amp;\
    rm -vf *.tgz

WORKDIR /src

RUN curl -sSfLO https://github.com/mattn/go-sqlite3/archive/refs/tags/v1.14.17.tar.gz &amp;&amp;\
    tar -xf v1.14.17.tar.gz

ENV GOOS=openbsd \
    GOARCH=goarm \
    CGO_ENABLED=1 \
    CC=clang-14 \
    CGO_CFLAGS="-O2 -g -v -target aarch64-openbsd --sysroot=$openbsd_root_arm64" \
    CGO_LDFLAGS="-v -target aarch64-openbsd -fuse-ld=lld --sysroot=$openbsd_root_arm64"

<p></details>

Diagnostics:

@Endilll
Copy link
Contributor

Endilll commented Oct 10, 2023

Confirmed on post-17 trunk: https://godbolt.org/z/4az7Gv55f
Reduced by C-Reduce:

void callbackTrampoline() {
  typedef struct {} _cgo_argtype;
  static _cgo_argtype _cgo_zero;
  _cgo_argtype _cgo_a = _cgo_zero;
}

Trunk crash:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -target aarch64-unknown-openbsd -x c <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'Post-RA pseudo instruction expansion pass' on function '@callbackTrampoline'
 #0 0x00000000037221d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37221d8)
 #1 0x000000000371fe9c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x371fe9c)
 #2 0x0000000003668a48 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f7978d74420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000000000e5aceb llvm::AArch64InstrInfo::expandPostRAPseudo(llvm::MachineInstr&) const (.part.0) AArch64InstrInfo.cpp:0:0
 #5 0x0000000002e67cbd (anonymous namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
 #6 0x0000000002afb5c1 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #7 0x00000000030a6509 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30a6509)
 #8 0x00000000030a6741 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30a6741)
 #9 0x00000000030a6f62 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30a6f62)
#10 0x00000000039968c2 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) BackendUtil.cpp:0:0
#11 0x0000000003996d69 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3996d69)
#12 0x000000000498cb8f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498cb8f)
#13 0x0000000005e8a819 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e8a819)
#14 0x000000000498bd78 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498bd78)
#15 0x00000000041f14f9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41f14f9)
#16 0x00000000041729ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41729ce)
#17 0x00000000042d069e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42d069e)
#18 0x0000000000bef2d6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbef2d6)
#19 0x0000000000be6b9a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#20 0x0000000003fceb99 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#21 0x0000000003668ef4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3668ef4)
#22 0x0000000003fcf18f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#23 0x0000000003f97355 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f97355)
#24 0x0000000003f97dbd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f97dbd)
#25 0x0000000003f9fce5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f9fce5)
#26 0x0000000000bec77c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbec77c)
#27 0x0000000000ae6c91 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xae6c91)
#28 0x00007f7978818083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x0000000000be667e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbe667e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)

@3405691582
Copy link
Contributor

3405691582 commented Jan 2, 2025

I'm seeing similar behavior with a reproducing case using -fblocks. I am guessing it might be related because this is also on OpenBSD and is failing in the same stage, but may be wrong.

Small reproducing case:

void f() {
   __block int i = 0;
   void (^b)() = ^(void) { i = 1; };
}

https://godbolt.org/z/Y1Ysbxson This seems like it's been a problem since 3.9.0 (!)

Can provide more details privately.

~/src/llvm/build/bin/clang -fblocks -c /tmp/a.c 
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: <snip>/clang -fblocks -c /tmp/a.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/tmp/a.c'.
4.      Running pass 'Post-RA pseudo instruction expansion pass' on function '@f'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang 0x000000127d3ee004 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 80
1  clang 0x000000127d3ec9d0 llvm::sys::RunSignalHandlers() + 148
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 20.0.0git (https://github.com/llvm/llvm-project dd30aa83aa12e5b2b5e58cb72ec85070f725df34)
Target: aarch64-unknown-openbsd7.5
<snip>

GDB backtrace:

#0  0x00000011eed9fe6c in llvm::AArch64InstrInfo::expandPostRAPseudo(llvm::MachineInstr&) const ()
#1  0x00000011f0780fcc [PAC] in (anonymous namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) ()
#2  0x00000011f04eba78 [PAC] in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()
#3  0x00000011f09a5148 [PAC] in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
#4  0x00000011f09ac2e0 [PAC] in llvm::FPPassManager::runOnModule(llvm::Module&)
    ()
#5  0x00000011f09a5cfc [PAC] in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
#6  0x00000011f1639618 [PAC] in clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >, clang::BackendConsumer*) ()
#7  0x00000011f1657c40 [PAC] in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) ()
#8  0x00000011f2f90988 [PAC] in clang::ParseAST(clang::Sema&, bool, bool) ()
#9  0x00000011f1a25d4c [PAC] in clang::FrontendAction::Execute() ()
#10 0x00000011f19b9f44 [PAC] in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
#11 0x00000011f1affbf8 [PAC] in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) ()
#12 0x00000011eecc162c [PAC] in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) ()
#13 0x00000011eecbf8a0 [PAC] in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) ()
#14 0x00000011f1841860 [PAC] in void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const::$_0>(long) ()
#15 0x00000011f0e9e81c [PAC] in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) ()
#16 0x00000011f18411b4 [PAC] in clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const ()
#17 0x00000011f180a470 [PAC] in clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const ()
#18 0x00000011f180a640 [PAC] in clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&, bool) const ()
#19 0x00000011f1821aa4 [PAC] in clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) ()
#20 0x00000011eecbeb70 [PAC] in clang_main(int, char**, llvm::ToolContext const&) ()
#21 0x00000011eeccaf90 [PAC] in main ()

@3405691582
Copy link
Contributor

A (not so ideal) workaround is to disable stack protection with -fno-stack-protector.

@3405691582
Copy link
Contributor

I believe #125416 should fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 crash Prefer [crash-on-valid] or [crash-on-invalid] platform:openbsd
Projects
None yet
Development

No branches or pull requests

4 participants