Skip to content

Commit 4a02764

Browse files
committed
[GR-18163] Add test for using a stripped C extension and fix strip options on macOS (#2697)
PullRequest: truffleruby/3445
2 parents 66bd905 + 8827eb5 commit 4a02764

File tree

11 files changed

+47
-11
lines changed

11 files changed

+47
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Bug fixes:
1111
* Fix `StringIO` to set position correctly after reading multi-byte characters (#2207, @aardvark179).
1212
* Update `Process` methods to use `module_function` (@bjfish).
1313
* Fix `File::Stat`'s `#executable?` and `#executable_real?` predicates that unconditionally returned `true` for a superuser (#2690, @andrykonchin).
14+
* The `strip` option `--keep-section=.llvmbc` is not supported on macOS (#2697, @eregon).
1415

1516
Compatibility:
1617

ci.jsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ local part_definitions = {
382382
test_cexts: {
383383
is_after+:: ["$.use.common"],
384384
# Only what is not already tested in other gates (e.g., C API and C ext specs are part of test_specs)
385-
run+: jt(["test", "mri", "--all-sulong"]) +
386-
jt(["test", "cexts"]) +
385+
run+: jt(["test", "cexts"]) +
386+
jt(["test", "mri", "--all-sulong"]) +
387387
jt(["test", "bundle"]),
388388
},
389389

lib/cext/ABI_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7
1+
8

lib/truffle/rbconfig.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ module RbConfig
6868
ranlib = Truffle::Boot.toolchain_executable(:RANLIB)
6969
strip = Truffle::Boot.toolchain_executable(:STRIP)
7070

71+
strip = "#{strip} --keep-section=.llvmbc" unless Truffle::Platform.darwin?
72+
7173
# Determine the various flags for native compilation
7274
optflags = ''
7375
debugflags = ''
@@ -188,7 +190,7 @@ module RbConfig
188190
'rubyarchhdrdir' => rubyhdrdir.dup,
189191
'rubyhdrdir' => rubyhdrdir,
190192
'SOEXT' => Truffle::Platform::SOEXT.dup,
191-
'STRIP' => "#{strip} --keep-section=.llvmbc",
193+
'STRIP' => strip,
192194
'sysconfdir' => "#{prefix}/etc", # doesn't exist, as in MRI
193195
'target_cpu' => host_cpu,
194196
'target_os' => host_os,

test/mri/excludes/FTPTest.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
exclude :test_getbinaryfile_command_injection, "needs investigation"
22
exclude :test_getbinaryfile_command_injection, "needs investigation"
33
exclude :test_putbinaryfile_command_injection, "hangs"
4+
exclude :test_list_read_timeout_exceeded, "transient"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'stripped/stripped'
4+
puts Stripped.stripped
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stripped!
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'mkmf'
2+
create_makefile('stripped')
3+
4+
contents = File.read('Makefile')
5+
contents = "hijack: all strip-ext\n\n" + contents + <<EOF
6+
strip-ext: $(DLLIB)
7+
$(ECHO) Stripping $(DLLIB)
8+
#{RbConfig::CONFIG['STRIP']} $(DLLIB)
9+
10+
.PHONY: strip-ext
11+
EOF
12+
File.write('Makefile', contents)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#include <ruby.h>
3+
4+
static VALUE stripped_stripped(VALUE self) {
5+
return rb_str_new_cstr("Stripped!");
6+
}
7+
8+
void Init_stripped() {
9+
VALUE mod = rb_define_module("Stripped");
10+
rb_define_singleton_method(mod, "stripped", stripped_stripped, 0);
11+
}

test/truffle/cexts/stripped/lib/stripped/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)