Skip to content

Commit 43e0571

Browse files
committed
Set install_name for libtrufflerubytrampoline
* So macOS actually looks in rpath instead of ignoring it...
1 parent ac02f14 commit 43e0571

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/c/cext-trampoline/Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,32 @@ endif
1111
# If that is the case and fails the build, it might be better to use instead:
1212
# CC := $(GRAALVM_TOOLCHAIN_CC)
1313

14-
# Same values as in RbConfig
14+
# Similar values as in RbConfig
1515
ifeq ($(OS),Darwin)
16-
CC := clang -fdeclspec
16+
CC := clang
17+
CFLAGS := -fdeclspec -Wall -Werror -fPIC -std=c99 -g
1718
else
1819
CC := gcc
20+
CFLAGS := -Wall -Werror -fPIC -std=c99 -g
1921
endif
2022

21-
CFLAGS := -Wall -Werror -fPIC -std=c99 -g
2223
LDFLAGS :=
2324

25+
ifeq ($(OS),Darwin)
26+
# Set the install_name of libtrufflerubytrampoline on macOS, so mkmf executables linking to it
27+
# will know they need to look at the rpath to find it.
28+
LIBS := -Wl,-install_name,@rpath/libtrufflerubytrampoline.$(SOEXT)
29+
else
30+
LIBS :=
31+
endif
32+
2433
ROOT := $(realpath ../../../..)
2534
RUBY_HDR_DIR := $(ROOT)/lib/cext/include
2635

2736
OBJECT_FILES := trampoline.o st.o strlcpy.o cext_constants.o
2837

2938
libtrufflerubytrampoline.$(SOEXT): $(OBJECT_FILES) Makefile
30-
$(Q) $(CC) -shared $(LDFLAGS) -o $@ $(OBJECT_FILES)
39+
$(Q) $(CC) -shared $(LDFLAGS) -o $@ $(OBJECT_FILES) $(LIBS)
3140

3241
%.o: %.c Makefile
3342
$(Q) $(CC) -o $@ -c $(CFLAGS) $(LDFLAGS) -I$(RUBY_HDR_DIR) -I$(ROOT)/lib/cext/include/stubs -I$(TRUFFLE_NFI_NATIVE_INCLUDE) $<

0 commit comments

Comments
 (0)