Repository navigation
lib/ExtUtils/t/Embed.t: failures on OpenBSD when compiling with gcc but not with clang #22125
Description
For several months I have been noticing smoke-test failures under certain configurations on OpenBSD-7.4; see, e.g., report 5052514. The failures occur when configuring a perl built with these command-line switches:
$ sh ./Configure -des -Dusedevel -Dcc=gcc -Accflags='-DPERL_RC_STACK -DDEBUG_LEAKING_SCALARS'
... and then, after running make test_prep, calling:
$ cd t; ./perl harness -v ../lib/ExtUtils/t/Embed.t; cd -
ld: error: undefined symbol: Perl_more_sv
>>> referenced by embed_test.c
>>> /tmp//ccE9t92Z.o:(S_new_SV)
ld: error: undefined symbol: PL_sv_serial
>>> referenced by embed_test.c
>>> /tmp//ccE9t92Z.o:(S_new_SV)
>>> referenced by embed_test.c
>>> /tmp//ccE9t92Z.o:(S_new_SV)
collect2: ld returned 1 exit status
not ok 1
not ok 10 # system returned -1
Failed 10/10 subtests
Test Summary Report
-------------------
../lib/ExtUtils/t/Embed.t (Wstat: 0 Tests: 2 Failed: 2)
Failed tests: 1, 10
Parse errors: Tests out of sequence. Found (10) but expected (2)
Bad plan. You planned 10 tests but ran 2.
Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.48 cusr 0.11 csys = 0.62 CPU)
Result: FAIL
I didn't pay these much attention at first because at first the perl was being built with a compiler I had never heard of, eg++. But more recently these failures were occuring with gcc as the compiler.
I haven't been able to install an OpenBSD more recent than 6.9, but I decided to explore this problem on that version today regardless. I got the test failure reported above on blead. I then decided to see whether these failures were due to a recent code change or whether @cjg-cguevara's exploration of these config options had merely revealed a problem that was "always" there. I tested at tag v5.38.0 and got the failure reported above.
$ uname -mrs
OpenBSD 6.9 amd64
$ gcc --version | head -1
gcc (GCC) 4.2.1 20070719
$ git show | head -3
commit 76298ae68aa7796f0ffc05095b127d23f4b2de8f
Author: Ricardo Signes <rjbs@semiotic.systems>
Date: Sat Jul 1 20:48:27 2023 -0400
$ sh ./Configure -des -Dusedevel -Dcc=gcc -Accflags='-DPERL_RC_STACK -DDEBUG_LEAKING_SCALARS'; make test_prep
$ ./perl -Ilib -V:config_args
config_args='-des -Dusedevel -Dcc=gcc -Accflags=-DPERL_RC_STACK -DDEBUG_LEAKING_SCALARS';
$ cd t; ./perl harness -v ../lib/ExtUtils/t/Embed.t; cd -
ld: error: undefined symbol: Perl_more_sv
>>> referenced by embed_test.c
>>> /tmp//ccE9t92Z.o:(S_new_SV)
ld: error: undefined symbol: PL_sv_serial
>>> referenced by embed_test.c
>>> /tmp//ccE9t92Z.o:(S_new_SV)
>>> referenced by embed_test.c
>>> /tmp//ccE9t92Z.o:(S_new_SV)
collect2: ld returned 1 exit status
not ok 1
not ok 10 # system returned -1
Failed 10/10 subtests
Test Summary Report
-------------------
../lib/ExtUtils/t/Embed.t (Wstat: 0 Tests: 2 Failed: 2)
Failed tests: 1, 10
Parse errors: Tests out of sequence. Found (10) but expected (2)
Bad plan. You planned 10 tests but ran 2.
Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.48 cusr 0.11 csys = 0.62 CPU)
Result: FAIL
Since the gcc version I was testing with dates back to 2007, I decided to try with the system's default C-compiler, clang-10.
$ clang --version >
OpenBSD clang version 10.0.1
Target: amd64-unknown-openbsd6.9
Thread model: posix
InstalledDir: /usr/bin
$ sh ./Configure -des -Dusedevel -Dcc=clang -Accflags='-DPERL_RC_STACK -DDEBUG_LEAKING_SCALARS'; make test_prep
With this more recent clang, the failing tests PASSed.
$ cd t; ./perl harness -v ../lib/ExtUtils/t/Embed.t; cd -
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10 # system returned 0
ok
All tests successful.
Files=1, Tests=10, 1 wallclock secs ( 0.01 usr 0.02 sys + 0.55 cusr 0.36 csys = 0.94 CPU)
Result: PASS
It would be good if someone could test these config options on an up-to-date OpenBSD with both gcc and clang. We can then try to evaluate the source of the test failures. cc: @afresh1
Activity
afresh1 commentedon Apr 7, 2024
I tried this on my -current sparc64 with both
-Dcc=clangand-Dcc=gcc.I did not see this failure in either case. Let me know if you need me to try something else or need access to an OpenBSD machine for testing.jkeenan commentedon Apr 7, 2024
And those were configured with
-Accflags='-DPERL_RC_STACK -DDEBUG_LEAKING_SCALARS'-- correct?[snip]
Is there some reason why OpenBSD's port of
gccremains at this version more than 16 years old (other than not wanting to use the GPL)? Should we even be bothering to test perls built withgccon OpenBSD?jkeenan commentedon Apr 7, 2024
Noting the 2 instances of
ld: error: undefined symbol ...:Further analysis needs more C-foo than I have.
jkeenan commentedon Apr 7, 2024
I should add that, as the above invocation suggests, I configured with each of the two options separately and learned that the test failure is being generated by
-DDEBUG_LEAKING_SCALARS. When I configure only with-DPERL_RC_STACKand build withgcc, the test PASSes.afresh1 commentedon Apr 7, 2024
Yes, I copied the incantation from the first message:
Just changing
=clangto=gccbetween them.I believe we have some architectures still that clang doesn't support and we are stuck with gcc, but where possible it is becoming the system compiler and when stable, we stop installing gcc.
And yes, it is because the clang licence is more acceptable to OpenBSD. I'm fairly sure we will not bring any GPL3 code into the base system at all.
iabyn commentedon Apr 8, 2024
jkeenan commentedon Apr 8, 2024
Bisecting on OpenBSD-6.9 with this invocation:
... confirmed the breaking commit:
jkeenan commentedon Apr 8, 2024
@richardleach ^^
richardleach commentedon Apr 9, 2024
Thanks, I'll try to look into this later this week
richardleach commentedon Apr 21, 2024
I'm assuming this is indeed an error by omission on my part, but haven't had chance to get an OpenBSD VM running yet.
tonycoz commentedon Apr 24, 2024
I had a look at this and reproduced it locally. libperl.a looks fine:
So what do we end up linking against? I edited
Embed.tto add-Wl,-tto the compiler invocation:So we're linking against the system libperl, which of course wasn't built with
-DDEBUG_LEAKING_SCALARSand doesn't definePL_sv_serial.So while 75acd14 revealed this problem, it didn't cause the problem.
26 remaining items
add API to test that libperl and the current executable are compatible
openbsd: ensure we link to the built libperl.a, not the system libperl.a
add API to test that libperl and the current executable are compatible
openbsd: ensure we link to the built libperl.a, not the system libperl.a
add API to test that libperl and the current executable are compatible
openbsd: ensure we link to the built libperl.a, not the system libperl.a
add API to test that libperl and the current executable are compatible
openbsd: ensure we link to the built libperl.a, not the system libperl.a
iabyn commentedon Jan 20, 2026
This seems to have stalled. Are the commits in PR #23265 suitable for merging, and if, so should we merge before 5.44.0?
tonycoz commentedon Jan 20, 2026
It doesn't resolve the problems from your comment but that's really a separate problem (and huge to solve generally).
add API to test that libperl and the current executable are compatible
openbsd: ensure we link to the built libperl.a, not the system libperl.a
add API to test that libperl and the current executable are compatible
openbsd: ensure we link to the built libperl.a, not the system libperl.a