Skip to content

Commit 04794cd

Browse files
committed
Build libtruffleposix in its own project
* So it can be added cleanly to TRUFFLERUBY_BOOTSTRAP_HOME.
1 parent 9b01fa0 commit 04794cd

File tree

5 files changed

+25
-51
lines changed

5 files changed

+25
-51
lines changed

mx.truffleruby/suite.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,24 @@
220220
"ldflags": ["-pthread"],
221221
},
222222

223+
"org.truffleruby.libtruffleposix": {
224+
"dir": "src/main/c/truffleposix",
225+
"native": "shared_lib",
226+
"deliverable": "truffleposix",
227+
"buildDependencies": [
228+
"TRUFFLERUBY_GRAALVM_SUPPORT_PLATFORM_AGNOSTIC",
229+
],
230+
"cflags": ["-g", "-O3", "-std=c99", "-Wall", "-Werror", "-pthread", "-I<path:TRUFFLERUBY_GRAALVM_SUPPORT_PLATFORM_AGNOSTIC>/lib/cext/include"],
231+
"ldflags": ["-pthread"],
232+
"os": {
233+
"linux": {
234+
"ldlibs": ["-lrt"],
235+
},
236+
"<others>": {
237+
},
238+
},
239+
},
240+
223241
"org.prism.libprism": {
224242
"class": "YARPNativeProject",
225243
"dir": "src/main/c/yarp",
@@ -405,7 +423,6 @@
405423
"output": ".",
406424
"results": [
407425
"src/main/c/spawn-helper/spawn-helper",
408-
"src/main/c/truffleposix/<lib:truffleposix>",
409426
"src/main/c/cext/<lib:truffleruby>",
410427
"src/main/c/cext-trampoline/<lib:trufflerubytrampoline>",
411428
"src/main/c/bigdecimal/<extsuffix:bigdecimal>",
@@ -750,8 +767,8 @@
750767
],
751768
"lib/cext/": [
752769
"file:lib/cext/*.rb",
753-
# libtruffleposix is handled specially in posix.rb to avoid a cyclic dependency between org.truffleruby.cext and TRUFFLERUBY-BOOTSTRAP-LAUNCHER
754770
"dependency:org.truffleruby.librubysignal",
771+
"dependency:org.truffleruby.libtruffleposix",
755772
],
756773
"lib/cext/include/": [
757774
"file:lib/cext/include/*",
@@ -805,10 +822,10 @@
805822
"dependency:org.prism.libprism.for.gem/build/<lib:prism>",
806823
],
807824
"lib/cext/": [
808-
"dependency:org.truffleruby.cext/src/main/c/truffleposix/<lib:truffleposix>",
825+
"dependency:org.truffleruby.librubysignal",
826+
"dependency:org.truffleruby.libtruffleposix",
809827
"dependency:org.truffleruby.cext/src/main/c/cext/<lib:truffleruby>",
810828
"dependency:org.truffleruby.cext/src/main/c/cext-trampoline/<lib:trufflerubytrampoline>",
811-
"dependency:org.truffleruby.librubysignal",
812829
],
813830
# Create the complete files to let RubyGems know the gems are fully built and can be activated
814831
"lib/gems/extensions/<cruby_arch>-<os>/<truffleruby_abi_version>/debug-1.9.2/gem.build_complete": "string:",
@@ -1073,7 +1090,7 @@
10731090
"TRUFFLERUBY",
10741091
"TRUFFLERUBY-RESOURCES",
10751092
],
1076-
"description" : "Truffle TCK provider for Ruby language.",
1093+
"description": "Truffle TCK provider for Ruby language.",
10771094
"license": ["EPL-2.0"],
10781095
"maven": {
10791096
"artifactId": "ruby-truffle-tck",

src/main/c/Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ endif
1717
ROOT := $(realpath ../../..)
1818
RUBY := $(TRUFFLERUBY_BOOTSTRAP_LAUNCHER)
1919

20-
TRUFFLE_POSIX := truffleposix/libtruffleposix.$(SOEXT)
2120
SPAWN_HELPER := spawn-helper/spawn-helper
2221
TRAMPOLINE := cext-trampoline/libtrufflerubytrampoline.$(SOEXT)
2322

@@ -26,7 +25,7 @@ CEXT_C_FILES := $(shell find cext -name '*.c')
2625
RBCONFIG := $(ROOT)/lib/truffle/rbconfig.rb
2726
MKMF := $(ROOT)/lib/mri/mkmf.rb
2827
LIBTRUFFLERUBY = cext/libtruffleruby.$(SOEXT)
29-
BASIC_DEPS := Makefile $(SPAWN_HELPER) $(TRUFFLE_POSIX) $(RUBY_HEADERS)
28+
BASIC_DEPS := Makefile $(SPAWN_HELPER) $(RUBY_HEADERS)
3029
BASIC_EXTCONF_DEPS := $(BASIC_DEPS) $(RBCONFIG) $(MKMF)
3130
# C extensions link against libtruffleruby (and might do have_func() checks against it), so it needs to be there before.
3231
# However, if libtruffleruby is recompiled, there is no need to rebuild C extensions, so it's a order-only-prerequisite.
@@ -42,10 +41,7 @@ all: $(TRAMPOLINE) $(LIBTRUFFLERUBY) openssl/openssl.$(DLEXT) zlib/zlib.$(DLEXT)
4241
bigdecimal/bigdecimal.$(DLEXT) date/date_core.$(DLEXT) io-console/console.$(DLEXT) etc/etc.$(DLEXT) \
4342
rbconfig-sizeof/sizeof.$(DLEXT) debug/debug.$(DLEXT) rbs/rbs_extension.$(DLEXT)
4443

45-
clean: clean_cexts clean_truffleposix clean_trampoline
46-
47-
clean_truffleposix:
48-
$(Q) rm -f $(TRUFFLE_POSIX) truffleposix/*.o
44+
clean: clean_cexts clean_trampoline
4945

5046
clean_trampoline:
5147
$(Q) rm -f $(TRAMPOLINE) cext-trampoline/trampoline.c cext/wrappers.c cext-trampoline/*.o
@@ -70,10 +66,6 @@ clean_cexts:
7066
$(SPAWN_HELPER): spawn-helper/Makefile spawn-helper/spawn-helper.c
7167
$(Q) cd spawn-helper && $(MAKE)
7268

73-
# truffleposix
74-
$(TRUFFLE_POSIX): truffleposix/Makefile truffleposix/truffleposix.c
75-
$(Q) cd truffleposix && $(MAKE)
76-
7769
# cext-trampoline
7870
cext-trampoline/trampoline.c: $(CEXT_C_FILES) $(BASIC_DEPS) $(ROOT)/tool/generate-cext-trampoline.rb
7971
$(Q) cd $(ROOT) && $(RUBY) tool/generate-cext-trampoline.rb

src/main/c/truffleposix/Makefile

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/ruby/truffleruby/core/posix.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ def resolve
3939
end
4040

4141
LIBTRUFFLEPOSIX = LazyLibrary.new do
42-
home = Truffle::Boot.ruby_home
43-
if Truffle::Boot.get_option 'building-core-cexts'
44-
repo = Truffle::System.get_java_property 'truffleruby.repository'
45-
libtruffleposix = "#{repo}/src/main/c/truffleposix/libtruffleposix.#{Truffle::Platform::SOEXT}"
46-
else
47-
libtruffleposix = "#{home}/lib/cext/libtruffleposix.#{Truffle::Platform::SOEXT}"
48-
end
42+
libtruffleposix = "#{Truffle::Boot.ruby_home}/lib/cext/libtruffleposix.#{Truffle::Platform::SOEXT}"
4943
Primitive.interop_eval_nfi "load '#{libtruffleposix}'"
5044
end
5145

0 commit comments

Comments
 (0)