-
-
Notifications
You must be signed in to change notification settings - Fork 785
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
ubuntu 21.10 clang 13环境下编译动态库加-flto编译选项后实际编译时-flto选项没有附加 #2281
Comments
cflags/cxxflags 是编译 flags 不是 linker flags,你只加了编译 flags,却在 linker flags 里找,怎么可能找到 shared 用 add_shflags, binary 用 add_ldflags |
谢谢,我看了xmake.io的文档加上了。这里还想问下,target B的源文件是target A编译后生成的,在target B中使用add_files添加了文件名,并add_deps了target A,在第一次使用xmake时,会报源文件未找到的错误,当然重新再编译一次就能OK, 有没有什么办法能一次编译成功么? 我在target B里使用before_link里调用target:add("files", "..."), 文件能加上,但没有生成.o文件。 |
谢谢你的回复,我看了下#1090, 好像也不能解决我提的这种情况,我用xmake创建了一个简单的project,你有空的时候帮忙看下: xmake.lua如下:
|
不同的问题 不要混一起,单开个 issues |
Xmake 版本
2.6.4
操作系统版本和架构
ubuntu 21.10 clang 13
描述问题
只有动态库有这个问题,看下面的编译信息:
[ 81%]: linking.release qjsc
/usr/bin/clang++ -o build/linux/x86_64/release/qjsc build/.objs/qjsc/linux/x86_64/release/qjsc.c.o -m64 -Lbuild/linux/x86_64/release -s -lquickjs.lto -lm -ldl -lpthread -flto
[ 87%]: linking.release qjs
/usr/bin/clang++ -o build/linux/x86_64/release/qjs build/.objs/qjs/linux/x86_64/release/qjs.c.o build/.objs/qjs/linux/x86_64/release/repl.c.o build/.objs/qjs/linux/x86_64/release/qjscalc.c.o -m64 -Lbuild/linux/x86_64/release -s -lquickjs.lto -lm -ldl -lpthread -flto -rdynamic
checking for clang++ ... /usr/bin/clang++
checking for the shared library linker (sh) ... clang++
checking for flags (-fPIC) ... ok
[ 93%]: linking.release curljs.so
/usr/bin/clang++ -o build/linux/x86_64/release/curljs.so build/.objs/curljs/linux/x86_64/release/qjs_cmod/curljs.c.o -shared -fPIC -m64 -L/usr/lib/x86_64-linux-gnu -Lbuild/linux/x86_64/release -s -lrt -lcrypto -lssl -lcurl -lquickjs.lto -lm -ldl -lpthread
error: build/.objs/curljs/linux/x86_64/release/qjs_cmod/curljs.c.o: file not recognized: file format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
手动加上-flto编译成功
xxxx@xxxx:/codes/js/quickjs/nqjspp$ /usr/bin/clang++ -o build/linux/x86_64/release/curljs.so build/.objs/curljs/linux/x86_64/release/qjs_cmod/curljs.c.o -shared -fPIC -m64 -L/usr/lib/x86_64-linux-gnu -Lbuild/linux/x86_64/release -s -lrt -lcrypto -lssl -lcurl -lquickjs.lto -lm -ldl -lpthread -flto
在xmake.lua中已经加上了:
add_cflags("-flto")
add_cxxflags("-flto")
在set_kind("shared")的target中,-flto编译时消失了。
期待的结果
编译动态库时-flto编译选项能正常附加
工程配置
No response
附加信息和错误日志
No response
The text was updated successfully, but these errors were encountered: