macOS 10.14.4 编译不通过
young40 opened this issue · 6 comments
young40 commented
➜ bee.lua git:(master) clang --version
Apple LLVM version 10.0.1 (clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
ninja 1.9.0
➜ bee.lua git:(master) ninja -f ninja/macos.ninja
[89/89] build/macos/bin/bootstrap test/test.lua
FAILED: build/macos/_/test
build/macos/bin/bootstrap test/test.lua
build/macos/bin/bootstrap: error loading module 'bee.filesystem' from file 'build/macos/bin/bee.so':
dlopen(build/macos/bin/bee.so, 6): Symbol not found: __ZNSt3__16__itoa8__u32toaEjPc
Referenced from: build/macos/bin/bee.so
Expected in: flat namespace
in build/macos/bin/bee.so
stack traceback:
[C]: in ?
[C]: in function 'require'
./test/test_platform.lua:49: in main chunk
[C]: in function 'require'
test/test.lua:21: in main chunk
/Users/young40/Work/Lua/bee.lua/build/macos/bin/main.lua:24: in main chunk
[C]: in ?
ninja: build stopped: subcommand failed.
actboy168 commented
1.我没有macos 10.4
2.欢迎提供pr
young40 commented
我从sumneko的lua-language-server过来的, 打算在macOS上编译一份lua的lsp server.
我今天研究了一下这个问题. 似乎是因为C++17引起的, 可能是macOS的自带的库不够新或者不够标准吧.
引起问题的代码是:
endpoint.cpp 里面的.
std::to_chars(portstr.data(), portstr.data() + portstr.size() - 1, port);
去掉这一句, 就能正常加载bee.so
从这里找到的一个例子:
https://zh.cppreference.com/w/cpp/utility/to_chars
放到Xcode 10.2里面运行.
也是会报
Undefined symbols for architecture x86_64:
"std::__1::__itoa::__u32toa(unsigned int, char*)", referenced from:
std::__1::__itoa::__traits_base<unsigned int, void>::__convert(unsigned int, char*) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我对c++17和bee.lua不太熟, 也还没看明白这句std::to_chars的作用.
不知道大神能否换一种写法来实现to_chars的功能.
actboy168 commented
to_chars是有备选方案的,如果没有charconv就会使用。你的编译器显然是有charconv,但却在link时失败了。我觉得是你的编译环境有问题。
Lines 98 to 109 in d75dd53
young40 commented
link也是成功的, 可以成功生成bee.so
失败的地方在运行单元测试失败了.
加载bee.so的时候失败了, 估计是macOS Runtime的问题.
还是非常感谢哈, 我再试一下不走charconv.
🙏
young40 commented
actboy168 commented
看起来clang对charconv的支持还不够好,我已经合并了你们的修改。如果仍然有问题,请让我知道。