-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Comments
@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 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:
BuildEnvironment:
Build Log:
</p> 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> 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"
<p></details> Diagnostics: |
Confirmed on post-17 trunk: https://godbolt.org/z/4az7Gv55f void callbackTrampoline() {
typedef struct {} _cgo_argtype;
static _cgo_argtype _cgo_zero;
_cgo_argtype _cgo_a = _cgo_zero;
} Trunk crash:
|
I'm seeing similar behavior with a reproducing case using Small reproducing case:
https://godbolt.org/z/Y1Ysbxson This seems like it's been a problem since 3.9.0 (!) Can provide more details privately.
GDB backtrace:
|
A (not so ideal) workaround is to disable stack protection with |
I believe #125416 should fix this issue. |
Summary
This build attempts to cross-compile the go-sqlite3's _example/simple Go project from a
linux/amd64
host to anopenbsd/arm64
target. However, clang appears to crash on the generated generated_cgo-exports.c
atRunning 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:
-Wl,--no-pie
flag correctly)Build
Environment:
Build Log:
go build -a -v .
Reproduction Steps:
These instructions are written using the below Dockerfile to make reproduction easier. Please let me know if more information is needed.
Dockerfile
Diagnostics:
The text was updated successfully, but these errors were encountered: