@@ -2302,25 +2302,6 @@ 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 Truffle ::Boot . get_option ( 'building-core-cexts' ) and target != 'libtruffleruby'
2306
- # Replace the -rpath argument in $LIBRUBYARG with a relative path to libtruffleruby for core C exts
2307
- # Relative path from lib/mri/$TARGET to lib/cext/libtruffleruby.so
2308
- nesting = target . count ( '/' )
2309
- target_dir_to_libtruffleruby_dir = "#{ '../' * nesting } ../cext"
2310
- if Truffle ::Platform . darwin?
2311
- origin_token = '@loader_path'
2312
- else
2313
- origin_token = '$$ORIGIN' # $$ so the Makefile does not expand it
2314
- end
2315
-
2316
- librubyarg = $LIBRUBYARG. split ( ' ' )
2317
- rpath_index = librubyarg . index ( '-rpath' )
2318
- raise 'Could not find -rpath in $LIBRUBYARG' unless rpath_index
2319
- # Extra quotes so the shell does not try to interpret $ORIGIN
2320
- librubyarg [ rpath_index + 1 ] = "'#{ origin_token } /#{ target_dir_to_libtruffleruby_dir } '"
2321
- $LIBRUBYARG = librubyarg . join ( ' ' )
2322
- end
2323
-
2324
2305
$target = target
2325
2306
libpath = $DEFLIBPATH|$LIBPATH
2326
2307
message "creating Makefile\n "
@@ -2839,6 +2820,12 @@ def MAIN_DOES_NOTHING(*refs)
2839
2820
"$(CC) #{ OUTFLAG } #{ CONFTEST } #{ $EXEEXT} $(INCFLAGS) $(CPPFLAGS) " \
2840
2821
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
2841
2822
2823
+ if defined? ( ::TruffleRuby )
2824
+ # We need to link to libtruffleruby for MakeMakefile#try_link to succeed
2825
+ libtruffleruby_dir = File . dirname ( RbConfig ::CONFIG [ 'libtruffleruby' ] )
2826
+ TRY_LINK << " -L#{ libtruffleruby_dir } -ltruffleruby"
2827
+ end
2828
+
2842
2829
##
2843
2830
# Command which will link a shared library
2844
2831
0 commit comments