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

Unrecognised emulation mode when building simple yasm project #962

Closed
abdelwahabzbal opened this issue Sep 19, 2020 · 4 comments
Closed

Comments

@abdelwahabzbal
Copy link

Describe the problem details

I'm trying to build simple Hello world program, then

$ xmake build -v
ld -o build/linux/x86_64/release/yasm build/.objs/yasm/linux/x86_64/release/main.s.o --dynamic-linker /lib/ld-linux-x86-64.so.2 -lc -m elf_x86_64 -s -L/usr/local/lib -L/usr/lib -m64
error: ld: unrecognised emulation mode: 64
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe

Question: Why -m64 is passed by default to linker (unrecognised) and how to remove them.

@waruqi
Copy link
Member

waruqi commented Sep 20, 2020

Can you let me see the whole configuration command and output.

xmake f --toolchain=yasm
xmake -rv

It works fine for me.

$ xmake f -c --toolchain=yasm
checking for architecture ... x86_64
$ xmake -rv
[ 40%]: ccache compiling.release src/main.S
/usr/bin/yasm -I/usr/local/include -I/usr/include -f elf64 -o build/.objs/test/linux/x86_64/release/src/main.S.o src/main.S
[ 60%]: ccache compiling.release src/stub.c
/usr/bin/ccache /usr/bin/gcc -c -I/usr/local/include -I/usr/include -m64 -o build/.objs/test/linux/x86_64/release/src/stub.c.o src/stub.c
[ 80%]: linking.release test
/usr/bin/g++ -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/src/main.S.o build/.objs/test/linux/x86_64/release/src/stub.c.o -L/usr/local/lib -L/usr/lib -m64
[100%]: build ok!

@abdelwahabzbal
Copy link
Author

abdelwahabzbal commented Sep 20, 2020

$ xmake f -c --toolchain=yasm
checking for the architecture ... x86_64
$ xmake -rv
checking for the g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
checking for the yasm ... /usr/bin/yasm
checking for the assember (as) ... yasm
checking for the ccache ... no
[ 50%]: compiling.release main.s
/usr/bin/yasm -I/usr/local/include -I/usr/include -f elf64 -o build/.objs/yasm/linux/x86_64/release/main.s.o main.s
[ 75%]: linking.release yasm
/usr/bin/g++ -o build/linux/x86_64/release/yasm build/.objs/yasm/linux/x86_64/release/main.s.o -s -L/usr/local/lib -L/usr/lib -m64
error: /usr/bin/ld: build/.objs/yasm/linux/x86_64/release/main.s.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIE

Fixed with :
$ xmake f -c --toolchain=yasm --ldflags="-no-pie"

@abdelwahabzbal
Copy link
Author

abdelwahabzbal commented Sep 20, 2020

But when we use linux ld
$ xmake config -c --toolchain=yasm --ld=ld
checking for the architecture ... x86_64
$ xmake -rv
checking for the yasm ... /usr/bin/yasm
checking for the assember (as) ... yasm
checking for the ccache ... no
[ 50%]: compiling.release main.s
/usr/bin/yasm -I/usr/local/include -I/usr/include -f elf64 -o build/.objs/yasm/linux/x86_64/release/main.s.o main.s
[ 75%]: linking.release yasm
ld -o build/linux/x86_64/release/yasm build/.objs/yasm/linux/x86_64/release/main.s.o -s -L/usr/local/lib -L/usr/lib -m64
error: ld: unrecognised emulation mode: 64
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe

@waruqi
Copy link
Member

waruqi commented Sep 20, 2020

Please do not directly set ld as the ld of xmake, xmake only uses g++/clang++ as the linker by default. If you want to modify the actual ld, you can use -fuse-ld=gold/lld to switch the internal ld linker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants