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

Failed to link Luau after Clang build in Linux #1210

Open
DoggyXomaX opened this issue Mar 24, 2024 · 0 comments
Open

Failed to link Luau after Clang build in Linux #1210

DoggyXomaX opened this issue Mar 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DoggyXomaX
Copy link

Trying to build Unigine game project with Luau.

  • On Windows it just build as intended.

  • On Linux it fails on final link with shared lib relocation problem:

[275/277] Linking CXX shared library scpdc/lua_system/libLuaSystem_plugin_x64.so
FAILED: scpdc/lua_system/libLuaSystem_plugin_x64.so 
: && /usr/bin/clang++ -fPIC -msse4.2 -fno-pic -O3 -DNDEBUG   -shared -Wl,-soname,libLuaSystem_plugin_x64.so -o scpdc/lua_system/libLuaSystem_plugin_x64.so scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaPlugin.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaState.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaWorldLogic.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaConsole.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaEngine.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaSound.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaMath.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/PropGenerator.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaXml.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaNode.cpp.o scpdc/lua_system/CMakeFiles/LuaSystem.dir/src/LuaProperty.cpp.o  -Wl,-rpath,/m/git/scpdc/bin  /m/git/scpdc/bin/libUnigine_x64.so  scpdc/core/libscpdc_core_x64.a  imgui/libImGui.a  _deps/luau-build/libLuau.VM.a  _deps/luau-build/libLuau.Compiler.a  /m/git/scpdc/bin/libUnigine_x64.so  _deps/luau-build/libLuau.Ast.a  _deps/luau-build/libLuau.CLI.lib.a && :
/usr/bin/ld: _deps/luau-build/libLuau.VM.a(lapi.cpp.o): relocation R_X86_64_32 against hidden symbol `luaO_nilobject_' can not be used when making a shared object
/usr/bin/ld: failed to set dynamic section sizes: bad value
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

CMakeLists.txt for luau:

...

# Disable C++ exceptions
if(MSVC)
    string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
endif()

# Add luau
CPMAddPackage(
    NAME Luau
    GIT_TAG 0.618
    GITHUB_REPOSITORY luau-lang/luau
    OPTIONS
    #"LUAU_BUILD_CLI OFF" # https://github.com/luau-lang/luau/issues/1208
    "LUAU_BUILD_TESTS OFF"
    "LUAU_BUILD_WEB OFF"
)
if(Luau_ADDED)
    file(COPY ${Luau_SOURCE_DIR}/tools/natvis/VM.natvis DESTINATION ${CMAKE_SOURCE_DIR}/natvis)
    target_sources(LuaSystem PRIVATE ${CMAKE_SOURCE_DIR}/natvis/VM.natvis)
endif()

# Add LuaBridge3
CPMAddPackage(
    NAME LuaBridge
    GITHUB_REPOSITORY kunitoki/LuaBridge3
    GIT_TAG 3.0-rc4
)
if(LuaBridge_ADDED)
    add_library(LuaBridge3 INTERFACE IMPORTED)
    target_include_directories(LuaBridge3 INTERFACE "${LuaBridge_SOURCE_DIR}/Distribution/LuaBridge")
endif()

target_link_libraries(LuaSystem
        PUBLIC Luau.VM LuaBridge3
        PRIVATE Luau.Compiler)
@DoggyXomaX DoggyXomaX added the bug Something isn't working label Mar 24, 2024
@DoggyXomaX DoggyXomaX changed the title Failed to link Luau in after Clang build in Linux Failed to link Luau after Clang build in Linux Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant