premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

clang compile c executable has no @rpath on macos

Open lailongwei opened this issue 1 year ago • 6 comments

bug

  • clang command generate executable, has no @rpath option add in linking phase, eg: -Wl,-rpath,@loader_path/.
  • system & architecture info:
    • system: mac Sequoia 15.0
    • arch: Apple M3(ARM64)

premake5 ver:

last commit info:

commit d842e671c7bc7e09f2eeaafd199fd01e48b87ee7 (HEAD -> master, origin/master, origin/HEAD)
Author: João Matos <[email protected]>
Date:   Mon Apr 29 17:08:41 2024 +0100

    Update Emscripten extension fork modules.md
    
    This just updates the URL to my fork, which is an up to date and mantained version.

premake5 generated compile command:

clang   -MD -MP -D_GLIBCXX_USE_CXX11_ABI=0 -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3  -O2 -g -Wall -Werror -Wno-strict-aliasing  -o "obj/release64/lullbc_luaexec/lua.o" -MF "obj/release64/lullbc_luaexec/lua.d" -c "../../wrap/lullbc/lua/lua.c"

additional info

If compile c++ file, will auto add -Wl,-rpath,@loader_path/. compile option when dll or exec generate

lailongwei avatar Sep 26 '24 08:09 lailongwei

You can try adding this to https://github.com/premake/premake-core/blob/master/premake5.lua#L197 :

    runpathdirs { "." }

tritao avatar Sep 26 '24 15:09 tritao

You can try adding this to https://github.com/premake/premake-core/blob/master/premake5.lua#L197 :

    runpathdirs { "." }

Thanks,runpathdirs is a good idea!

I try to fix this bug using below methods:

-- method 1:
filter { "system:macosx" }
    linkoptions { "-Wl,-rpath,@loader_path" }
filter {}

-- method 2(a mre elegant method):
filter { "system:macosx" }
    runpathdirs { "@loader_path" }
filter {}

lailongwei avatar Sep 27 '24 01:09 lailongwei

You can try adding this to https://github.com/premake/premake-core/blob/master/premake5.lua#L197 :

    runpathdirs { "." }

I think this is a premake tool bug, I hope premake's developers can fix it

lailongwei avatar Sep 27 '24 01:09 lailongwei

Unfortunately, I don't have an apple device to verify a build. If someone would put forward a PR with tests, I'd happily review it.

nickclark2016 avatar Sep 27 '24 02:09 nickclark2016

Unfortunately, I don't have an apple device to verify a build. If someone would put forward a PR with tests, I'd happily review it.

Haha.... May be I can try to fix it :) please keep this issue open.

lailongwei avatar Sep 27 '24 02:09 lailongwei

I do not plan on closing this :)

nickclark2016 avatar Sep 27 '24 02:09 nickclark2016