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

"./asm_offset: Exec format error" when building for arm64 #881

Closed
kexia01 opened this issue Mar 16, 2022 · 5 comments · Fixed by #1019
Closed

"./asm_offset: Exec format error" when building for arm64 #881

kexia01 opened this issue Mar 16, 2022 · 5 comments · Fixed by #1019
Assignees
Labels
bug Something isn't working build Anything to do with building the repo

Comments

@kexia01
Copy link

kexia01 commented Mar 16, 2022

I want to build loader for arm64,
set(CMAKE_SYSTEM_PROCESSOR "aarch64") in loader/CMakeList.txt
and export CC/CXX.
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++

Then, build as the following command:
mkdir build
cd build
../scripts/update_deps.py
cmake -C helper.cmake ..
cmake --build .

Log for cmake -C:
-- Check for working C compiler: /tools/gcc_aarch64/4.9_2014.07/bin/aarch64-linux-gnu-gcc
-- Check for working CXX compiler: /tools/gcc_aarch64/4.9_2014.07/bin/aarch64-linux-gnu-gcc
-- The ASM compiler identification is GNU
-- Found assembler: /tools/gcc_aarch64/4.9_2014.07/bin/aarch64-linux-gnu-gcc

Error for build:
k01@a01-lin:~/work/source/Vulkan-Loader/build$ cmake --build .
Scanning dependencies of target asm_offset
[ 5%] Building C object loader/CMakeFiles/asm_offset.dir/asm_offset.c.o
[ 10%] Linking C executable asm_offset
[ 10%] Built target asm_offset
Scanning dependencies of target loader_asm_gen_files
[ 15%] Generating gen_defines.asm
/bin/sh: 1: ./asm_offset: Exec format error
loader/CMakeFiles/loader_asm_gen_files.dir/build.make:79: recipe for target 'loader/gen_defines.asm' failed
make[2]: *** [loader/gen_defines.asm] Error 2
CMakeFiles/Makefile2:171: recipe for target 'loader/CMakeFiles/loader_asm_gen_files.dir/all' failed
make[1]: *** [loader/CMakeFiles/loader_asm_gen_files.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2

@kexia01
Copy link
Author

kexia01 commented Mar 16, 2022

If export asm:
export ASM=aarch64-linux-gnu-as

-- The ASM compiler identification is GNU
-- Found assembler: /tools/gcc_aarch64/4.9_2014.07/bin/aarch64-linux-gnu-as

Building error is the same.

@jyangsh
Copy link

jyangsh commented Mar 16, 2022

looks the change is introduced by PR #731 . @esullivan-nvidia

@SupervisedThinking
Copy link
Contributor

Is your buildsystem aarch64 too? If not you need to build a x86 asm_offset binary first & reuse it for the aarch64 build...

@Mindavi
Copy link

Mindavi commented May 3, 2022

Running into this within nixpkgs as well. This is what the cmake boot/manual recommends doing: https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#running-executables-built-in-the-project

Kinda makes me sad to have to deal with that, but I guess it's kinda inevitable since cmake doesn't support compiling for build and target system in one go.

NixOS/nixpkgs#170366 (comment)

Trying to cross-compile from x86_64 to aarch64.

Gonna try setting -DUSE_GAS=OFF, but I'm not sure what the implications are there. I saw some warnings about tail-call optimization being mandatory or so?

@charles-lunarg
Copy link
Collaborator

This appears to be the same as #249 as the issue is that cross-compilation is not support supported due to asm_offset needing to be run. /bin/sh: 1: ./asm_offset: Exec format error indicates that cmake tries to run the built executable but fails to do so, thus failing to generate the gen_defines.asm file and failing the build.

This is a bug, and I am working on a fix for cross compilation that is discussed further in the linked issue.

@charles-lunarg charles-lunarg self-assigned this Sep 13, 2022
@charles-lunarg charles-lunarg added bug Something isn't working build Anything to do with building the repo labels Sep 13, 2022
dmrlawson added a commit to dmrlawson/Lakka-LibreELEC that referenced this issue Sep 17, 2022
Might be needed for all aarch64 until KhronosGroup/Vulkan-Loader#881 is fixed
Ntemis pushed a commit to libretro/Lakka-LibreELEC that referenced this issue Sep 18, 2022
* vulkan-loader: require xrandr when using x11

* vulkan-loader: USE_GAS=OFF for Odin

Might be needed for all aarch64 until KhronosGroup/Vulkan-Loader#881 is fixed

* mergerfs: downgrade to fix build

* xf86-input-libinput: require xorg-server

* Odin: WINDOWMANAGER 'none' -> 'no'

* xorg-server: add patch for drmmode_display.c build error

* Odin: delete a bunch of custom packages

* mesa: couple of bits from v4.x
ToKe79 pushed a commit to libretro/Lakka-LibreELEC that referenced this issue Jan 21, 2023
* vulkan-loader: require xrandr when using x11

* vulkan-loader: USE_GAS=OFF for Odin

Might be needed for all aarch64 until KhronosGroup/Vulkan-Loader#881 is fixed

* mergerfs: downgrade to fix build

* xf86-input-libinput: require xorg-server

* Odin: WINDOWMANAGER 'none' -> 'no'

* xorg-server: add patch for drmmode_display.c build error

* Odin: delete a bunch of custom packages

* mesa: couple of bits from v4.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Anything to do with building the repo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants