xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.57k stars 763 forks source link

NDK set_runtimes("c++_shared") not work as expected #5113

Open 19317362 opened 2 months ago

19317362 commented 2 months ago

Xmake Version

2.9.1

Operating System Version and Architecture

Windows

Describe Bug

I'm test a simple hello-world app with NDK R26D. I want use NDK c++_shared STL. So I use set_runtimes("c++_shared") in xmake.lua.

Expected Behavior

readelf -d hell-world | grep NEEDED to inspect the app, it use [libc++_shared.so] But it was not.

And then, I tried config like rm -rf .xmake; rm -rf build;xmake f -y -p android --runtimes=c++_shared, than run fromelf to inspect the app, it shows as expectd.

 0x00000001 (NEEDED)                     Shared library: [libc++_shared.so]

Project Configuration

xmake f -y -p android

set_runtimes("c++_shared")
target("hello-world")
    set_kind("binary")
    add_files("src/*.cpp")

Additional Information and Error Logs

When use xmake -v to inspect the command line, it has -static-libstdc++ which is not as expected

android-ndk-r26d\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++
-o
build\android\armeabi-v7a\release\yca_app
build\.objs\yca_app\android\armeabi-v7a\release\yca\yca_app.cpp.o
-target
armv7-none-linux-androideabi33
-fPIE
-pie
-static-libstdc++
-mthumb
-Lbuild\android\armeabi-v7a\release
-Wl,-rpath=$ORIGIN
-s
-latomic
-rdynamic
-Wl,--hash-style=sysv

After config with rm -rf .xmake; rm -rf build;xmake f -y -p android --runtimes=c++_shared, the command line is OK without -static-libstdc++

android-ndk-r26d\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++
-o
build\android\armeabi-v7a\release\yca_app
build\.objs\yca_app\android\armeabi-v7a\release\yca\yca_app.cpp.o
-target
armv7-none-linux-androideabi33
-fPIE
-pie
-mthumb
-Lbuild\android\armeabi-v7a\release
-Wl,-rpath=$ORIGIN
-s
-latomic
-rdynamic
-Wl,--hash-style=sysv
waruqi commented 2 months ago

ndk does not support set_runtimes() now.