gvvaughan / lyaml

LibYAML binding for Lua.
gvvaughan.github.io/lyaml
Other
209 stars 34 forks source link

Unable to override LIBFLAG within Luke #23

Closed sparked435 closed 7 years ago

sparked435 commented 7 years ago

On NetBSD, a special linker flag needs to be passed for ld.so to correctly load dependencies in nonstandard places - which unfortunately includes /usr/pkg/lib.

It's pretty routine to override LDFLAGS or similar when building with LuaRocks for that reason. However, this package fails:

Nov01:2043  $ sudo luarocks-5.2 install lyaml YAML_DIR=/usr/pkg LIBFLAG='-shared -Wl,-R/usr/pkg/lib'
Warning: falling back to curl - install luasec to get native HTTPS support
Installing https://luarocks.org/lyaml-6.1.3-1.src.rock
/usr/pkg/bin/lua5.2 build-aux/luke package="lyaml" version="6.1.3-1" PREFIX="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1" CFLAGS="-O2 -fPIC" LIBFLAG="-shared -Wl,-R/usr/pkg/lib" LIB_EXTENSION="so" OBJ_EXTENSION="o" LUA="/usr/pkg/bin/lua5.2" LUA_DIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1/lua" LUA_INCDIR="/usr/pkg/include/lua-5.2" YAML_DIR="/usr/pkg" YAML_INCDIR="/usr/pkg/include" YAML_LIBDIR="/usr/pkg/lib"
creating build-aux/config.ld
cc -O2 -fPIC -shared -fPIC   -DNDEBUG -D_FORTIFY_SOURCE=2 -D_BSD_SOURCE -DVERSION='"6.1.3-1"' -DPACKAGE='"lyaml"' -Iext/include -I/usr/pkg/include/lua-5.2 -I/usr/pkg/include ext/yaml/yaml.c ext/yaml/emitter.c ext/yaml/parser.c ext/yaml/scanner.c -o netbsd/yaml.so -L/usr/pkg/lib  -lyaml
true -c build-aux/config.ld .
/usr/pkg/bin/lua5.2 build-aux/luke install --quiet INST_LIBDIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1/lib" INST_LUADIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1/lua"
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
lyaml 6.1.3-1 is now installed in /usr/pkg/luarocks (license: MIT/X11)

Nov01:2043 $ ldd /usr/pkg/luarocks/lib/lua/5.2/yaml.so 
/usr/pkg/luarocks/lib/lua/5.2/yaml.so:
        -lyaml-0.2 => not found
        -lgcc_s.1 => /usr/lib/libgcc_s.so.1
        -lc.12 => /usr/lib/libc.so.12

You can see in the above that LIBFLAG gets passed down somewhat, but doesn't make it all the way to the CC command (the option '-Wl,-R/usr/pkg/lib' is missing), and thus loading yaml.so fails.

gvvaughan commented 7 years ago

Thanks for the report.

Turns out I had been spelling it LIBFLAGS in luke, for consistency with CFLAGS and LDFLAGS, but using Luarocks' spelling LIBFLAG in the rockspec file. I fixed luke upstream, and imported the latest version, which now works for me!