Skip to content
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

You cannot compile when using cross compilation #86

Open
xmiyang opened this issue Apr 23, 2023 · 12 comments
Open

You cannot compile when using cross compilation #86

xmiyang opened this issue Apr 23, 2023 · 12 comments
Labels
question Further information is requested

Comments

@xmiyang
Copy link

xmiyang commented Apr 23, 2023

CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CXX=/media/sd1data/opt/rockchip_rk3568/host/bin/aarch64-linux-g++ go build -o shmViewV2_main main.go

# runtime/cgo gcc_arm64.S: Assembler messages: gcc_arm64.S:28: Error: no such instruction: stp x29,x30,[sp,'
gcc_arm64.S:32: Error: too many memory references for mov' gcc_arm64.S:34: Error: no such instruction: stp x19,x20,[sp,'
gcc_arm64.S:37: Error: no such instruction: stp x21,x22,[sp,' gcc_arm64.S:40: Error: no such instruction: stp x23,x24,[sp,'
gcc_arm64.S:43: Error: no such instruction: stp x25,x26,[sp,' gcc_arm64.S:46: Error: no such instruction: stp x27,x28,[sp,'
gcc_arm64.S:50: Error: too many memory references for mov' gcc_arm64.S:51: Error: too many memory references for mov'
gcc_arm64.S:52: Error: too many memory references for mov' gcc_arm64.S:54: Error: no such instruction: blr x20'
gcc_arm64.S:55: Error: no such instruction: blr x19' gcc_arm64.S:57: Error: no such instruction: ldp x27,x28,[sp,'
gcc_arm64.S:60: Error: no such instruction: ldp x25,x26,[sp,' gcc_arm64.S:63: Error: no such instruction: ldp x23,x24,[sp,'
gcc_arm64.S:66: Error: no such instruction: ldp x21,x22,[sp,' gcc_arm64.S:69: Error: no such instruction: ldp x19,x20,[sp,'
gcc_arm64.S:72: Error: no such instruction: ldp x29,x30,[sp],'

@marcboeker
Copy link
Owner

Have you tried compiling DuckDB on Linux/arm64? Looks like that DuckDB could not be compiled with your toolchain.

@xmiyang
Copy link
Author

xmiyang commented Apr 25, 2023

Have you tried compiling DuckDB on Linux/arm64? Looks like that DuckDB could not be compiled with your toolchain.

The compile command is as follows:CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc go build main.go

Does duckdb not support compilation under the linux arm64 architecture?

@xmiyang
Copy link
Author

xmiyang commented Apr 25, 2023

Have you tried compiling DuckDB on Linux/arm64? Looks like that DuckDB could not be compiled with your toolchain.

I tried to compile in the linux arm64 ,It did not compile successfully. Duckdb is supported by linux arm64, does not need to add a layer of encapsulation or static library.

@marcboeker
Copy link
Owner

Have you tried linking against the aarch64 libs provided by DuckDB using:

CGO_ENABLED=1 CGO_LDFLAGS="-L/path/to/libs" go build -tags=duckdb_use_lib main.go LD_LIBRARY_PATH=/path/to/libs ./main

@xmiyang
Copy link
Author

xmiyang commented Apr 26, 2023

LD_LIBRARY_PATH=

This approach still doesn't solve my problem.Can you compile properly this way? I don't know what the problem is. He's been bothering me for three days. Your help is badly needed. Be grateful

@marcboeker
Copy link
Owner

marcboeker commented Apr 27, 2023

Have you tried this golang/go#28966 ?

@begelundmuller
Copy link
Contributor

Hey @xmiyang, this repo doesn't have a precompiled static library for linux/arm64, but if dynamically linking like @marcboeker suggested doesn't work for you, you could also consider building DuckDB from source by passing -tags=duckdb_from_source.

@xmiyang
Copy link
Author

xmiyang commented May 8, 2023

Hey @xmiyang, this repo doesn't have a precompiled static library for linux/arm64, but if dynamically linking like @marcboeker suggested doesn't work for you, you could also consider building DuckDB from source by passing -tags=duckdb_from_source.

How exactly do you use it? Can you add it directly to the repo?

@xmiyang
Copy link
Author

xmiyang commented May 8, 2023

Hey @xmiyang, this repo doesn't have a precompiled static library for linux/arm64, but if dynamically linking like @marcboeker suggested doesn't work for you, you could also consider building DuckDB from source by passing -tags=duckdb_from_source.

I really don't know how to complete the compilation, I have tried a lot of ways, still encountered a lot of errors

@marcboeker
Copy link
Owner

First of all you should make sure, that you are able to compile DuckDB from source. If that's working, then you should link to the DuckDB libs, that you have compiled.

Please get the sources from the latest DuckDB release and run make in the directory to see, if your toolchain can compile DuckDB. Once that's done, locate the libduckdb.a in the source folder and link against it while building and executing your app.

# Build
CGO_ENABLED=1 CGO_LDFLAGS="-L/path/to/libs" go build -tags=duckdb_use_lib main.go

# Run
LD_LIBRARY_PATH=/path/to/libs ./main

/path/to/libs is where the libduckdb.a is located.

@kndndrj
Copy link

kndndrj commented May 17, 2023

+1
I'm working on a project which depends heavily on cross-compilation.
If you by any chance want to have a look at the ci pipeline, where this is being build:
https://github.com/kndndrj/nvim-dbee/actions/runs/5006378568

@xmiyang
Copy link
Author

xmiyang commented May 18, 2023

+1 我正从一个严重依赖交译的项目开始。 如果您有机会想看正确在构建的ci管理路径: https://github.com/kndndrj/nvim-dbee/actions/runs/50063 78568

Is there a way to fix this?

@marcboeker marcboeker added the question Further information is requested label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants