Skip to content

Commit 633b8b6

Browse files
committed
Replace the only usage of truffle.h with a prototype declaration
1 parent 6176ec1 commit 633b8b6

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

lib/cext/include/truffleruby/truffleruby-pre.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ extern "C" {
2020

2121
#define TRUFFLERUBY
2222

23-
#ifdef SULONG_TRUFFLE_H
24-
#include SULONG_TRUFFLE_H
25-
#else
26-
#include <sulong/truffle.h>
27-
#endif
28-
2923
#ifdef SULONG_POLYGLOT_H
3024
#include SULONG_POLYGLOT_H
3125
#else

lib/truffle/rbconfig-for-mkmf.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@
9797

9898
relative_debug_paths = "-fdebug-prefix-map=#{ruby_home}=."
9999
polyglot_h = "-DSULONG_POLYGLOT_H='\"#{ENV.fetch('SULONG_POLYGLOT_H')}\"'"
100-
truffle_h = "-DSULONG_TRUFFLE_H='\"#{ENV.fetch('SULONG_TRUFFLE_H')}\"'"
101-
mkconfig['CPPFLAGS'] = "#{relative_debug_paths} #{polyglot_h} #{truffle_h}"
100+
mkconfig['CPPFLAGS'] = "#{relative_debug_paths} #{polyglot_h}"
102101
expanded['CPPFLAGS'] = mkconfig['CPPFLAGS']
103102

104103
# Default to the ruby in $PATH to build core C extensions faster

mx.truffleruby/suite.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,11 @@
257257
"TRUFFLERUBY-LAUNCHER", # We need this jar to run extconf.rb
258258
"truffle:TRUFFLE_NFI_NATIVE", # trufflenfi.h
259259
"sulong:SULONG_HOME", # polyglot.h
260-
"sulong:SULONG_LEGACY", # truffle.h
261260
],
262261
"buildEnv": {
263262
"NFI_HEADERS_DIR": "<path:truffle:TRUFFLE_NFI_NATIVE>/include",
264263
"SULONG_HEADERS_DIR": "<path:SULONG_HOME>/include",
265264
"SULONG_POLYGLOT_H": "<path:SULONG_HOME>/include/polyglot.h",
266-
"SULONG_TRUFFLE_H": "<path:SULONG_LEGACY>/include/truffle.h",
267-
"SULONG_TRUFFLE_DIR": "<path:SULONG_LEGACY>/include",
268265
},
269266
"output": ".",
270267
"results": [
@@ -425,7 +422,6 @@
425422
"file:lib/cext/include/*.h",
426423
],
427424
"lib/cext/include/sulong/": [
428-
"extracted-dependency:sulong:SULONG_LEGACY/include/truffle.h",
429425
"link:../../sulong-libs/include/polyglot.h",
430426
],
431427
"lib/cext/sulong-libs/": [

src/main/c/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CFLAGS := -Wall -Werror -Wno-unused-function -fPIC -std=c99
1717
LDFLAGS := -m64
1818

1919
TRUFFLE_POSIX := truffleposix/libtruffleposix.$(DLEXT)
20-
SULONG_HEADERS := $(SULONG_TRUFFLE_H) $(SULONG_POLYGLOT_H)
20+
SULONG_HEADERS := $(SULONG_POLYGLOT_H)
2121
GENERATE_SULONG_MOCK := $(ROOT)/tool/generate-sulongmock.rb
2222

2323
RUBY_HEADERS := $(wildcard $(ROOT)/lib/cext/include/*.h) $(wildcard $(ROOT)/lib/cext/include/*/*.h) $(wildcard $(ROOT)/lib/cext/include/*/*/*.h)
@@ -60,11 +60,11 @@ sulongmock/sulongmock.c: $(GENERATE_SULONG_MOCK) $(SULONG_HEADERS) $(TRUFFLE_POS
6060
$(RUBY) $(GENERATE_SULONG_MOCK) $(SULONG_HEADERS)
6161

6262
sulongmock/sulongmock.o: sulongmock/sulongmock.c
63-
$(CC) -o $@ -c $(CFLAGS) $(LDFLAGS) -I$(ROOT)/lib/cext/include -I$(SULONG_TRUFFLE_DIR) -I$(SULONG_HEADERS_DIR) $<
63+
$(CC) -o $@ -c $(CFLAGS) $(LDFLAGS) -I$(ROOT)/lib/cext/include -I$(SULONG_HEADERS_DIR) $<
6464

6565
# ruby.o
6666
cext/ruby.o: cext/*.c $(RUBY_HEADERS)
67-
$(CC) -o $@ -c $(CFLAGS) $(LDFLAGS) -DSULONG_TRUFFLE_H=\"$(SULONG_TRUFFLE_H)\" -DSULONG_POLYGLOT_H=\"$(SULONG_POLYGLOT_H)\" -I$(ROOT)/lib/cext/include cext/ruby.c
67+
$(CC) -o $@ -c $(CFLAGS) $(LDFLAGS) -DSULONG_POLYGLOT_H=\"$(SULONG_POLYGLOT_H)\" -I$(ROOT)/lib/cext/include cext/ruby.c
6868

6969
# ruby.su
7070
cext/Makefile: cext/extconf.rb $(BASIC_EXTCONF_DEPS)

src/main/c/cext/ruby.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,6 +2904,9 @@ void* rb_tr_new_managed_struct_internal(void *type) {
29042904
return polyglot_invoke(RUBY_CEXT, "rb_tr_new_managed_struct", type);
29052905
}
29062906

2907+
// Deprecated truffle LLVM intrinsic only used internally here
2908+
void truffle_load_library(const char *string);
2909+
29072910
void rb_tr_load_library(VALUE library) {
29082911
truffle_load_library(RSTRING_PTR(library));
29092912
}

tool/generate-sulongmock.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@
2525
break if line.start_with?('#ifdef DOXYGEN')
2626
next if line.start_with?('//') || line.start_with?(' *')
2727

28-
match = /^(\S.+?)\b(truffle|polyglot|__polyglot)(.+)\)(?=;)/.match(line)
28+
match = /^(\S.+?)\b(polyglot|__polyglot)(.+)\)(?=;)/.match(line)
2929
if match
3030
signature, return_type = match[0], match[1]
3131
return_value = types.fetch(return_type.gsub(' ', ''), '0')
3232
methods << [signature, return_value]
3333
end
3434
end
3535

36+
methods << ['void truffle_load_library(const char *string)', nil]
37+
3638
File.write('src/main/c/sulongmock/sulongmock.c', ERB.new(<<TRC).result)
3739
/*
3840
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. This
@@ -49,7 +51,7 @@
4951
5052
#include <stdio.h>
5153
#include <stdint.h>
52-
#include <truffle.h>
54+
#include <stdlib.h>
5355
#include <polyglot.h>
5456
5557
void rb_tr_mock() {

0 commit comments

Comments
 (0)