@@ -2302,6 +2302,16 @@ def depend_rules(depend)
2302
2302
# +VPATH+ and added to the list of +INCFLAGS+.
2303
2303
#
2304
2304
def create_makefile ( target , srcprefix = nil )
2305
+ if defined? ( ::TruffleRuby ) and $LIBRUBYARG. to_s . strip . empty?
2306
+ # $LIBRUBYARG was explicitly unset, the built library is not a C extension but used with FFI (e.g., sassc does).
2307
+ # Since $LIBRUBYARG is unset we won't link to libgraalvm-llvm.so, which is wanted.
2308
+ # In the case the library uses C++ code, libc++.so/libc++abi.so will be linked and needs to be found by NFI.
2309
+ # The toolchain does not pass -rpath automatically for libc++.so/libc++abi.so, so we do it.
2310
+ libcxx_dir = ::Truffle ::Boot . toolchain_paths ( :LD_LIBRARY_PATH )
2311
+ raise 'libcxx_dir should not be empty' if libcxx_dir . empty?
2312
+ $DLDFLAGS << " -rpath #{ libcxx_dir } "
2313
+ end
2314
+
2305
2315
$target = target
2306
2316
libpath = $DEFLIBPATH|$LIBPATH
2307
2317
message "creating Makefile\n "
@@ -2650,7 +2660,9 @@ def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG)
2650
2660
$LIBRUBYARG = ""
2651
2661
$LIBRUBYARG_STATIC = config [ 'LIBRUBYARG_STATIC' ]
2652
2662
$LIBRUBYARG_SHARED = config [ 'LIBRUBYARG_SHARED' ]
2653
- $DEFLIBPATH = [ $extmk ? "$(topdir)" : "$(#{ config [ "libdirname" ] || "libdir" } )" ]
2663
+ # TruffleRuby: no need to add libdir to rpath of C exts, since we do not link to libtruffleruby (GR-29448)
2664
+ # That way, C extensions do not depend on a specific TruffleRuby build.
2665
+ $DEFLIBPATH = defined? ( ::TruffleRuby ) ? [ ] : [ $extmk ? "$(topdir)" : "$(#{ config [ "libdirname" ] || "libdir" } )" ]
2654
2666
$DEFLIBPATH. unshift ( "." )
2655
2667
$LIBPATH = [ ]
2656
2668
$INSTALLFILES = [ ]
0 commit comments