During an exp-run for llvm 15 (see bug 265425), it turned out that lang/perl5.32, lang/perl5.34, lang/perl5.36 and lang/perl5-devel fail to build with clang and lld 15: cc -pthread -Wl,-E -fstack-protector-strong -L/usr/local/lib -o miniperl mpdtrace/opmini.o mpdtrace/perlmini.o mpdtrace/gv.o mpdtrace/toke.o mpdtrace/perly.o mpdtrace/pad.o mpdtrace/regcomp.o mpdtrace/dump.o mpdtrace/util.o mpdtrace/mg.o mpdtrace/reentr.o mpdtrace/mro_core.o mpdtrace/keywords.o mpdtrace/hv.o mpdtrace/av.o mpdtrace/run.o mpdtrace/pp_hot.o mpdtrace/sv.o mpdtrace/pp.o mpdtrace/scope.o mpdtrace/pp_ctl.o mpdtrace/pp_sys.o mpdtrace/doop.o mpdtrace/doio.o mpdtrace/regexec.o mpdtrace/utf8.o mpdtrace/taint.o mpdtrace/deb.o mpdtrace/universal.o mpdtrace/globals.o mpdtrace/perlio.o mpdtrace/perlapi.o mpdtrace/numeric.o mpdtrace/mathoms.o mpdtrace/locale.o mpdtrace/pp_pack.o mpdtrace/pp_sort.o mpdtrace/caretx.o mpdtrace/dquote.o mpdtrace/time64.o mpdtrace/miniperlmain.o dtrace_mini.o -lpthread -lm -lcrypt -lutil ld: error: duplicate symbol: __dtraceenabled_perl___op__entry >>> defined in mpdtrace/perlmini.o >>> defined in mpdtrace/dump.o ld: error: duplicate symbol: __dtraceenabled_perl___op__entry >>> defined in mpdtrace/perlmini.o >>> defined in mpdtrace/run.o ld: error: duplicate symbol: __dtraceenabled_perl___sub__entry >>> defined in mpdtrace/pp_hot.o >>> defined in mpdtrace/pp_ctl.o ld: error: duplicate symbol: __dtraceenabled_perl___sub__entry >>> defined in mpdtrace/pp_hot.o >>> defined in mpdtrace/regexec.o ld: error: duplicate symbol: __dtraceenabled_perl___sub__entry >>> defined in mpdtrace/pp_hot.o >>> defined in mpdtrace/pp_sort.o cc: error: linker command failed with exit code 1 (use -v to see invocation) *** Error code 1 This error pops up in more bug reports, for instance bug 258872 and bug 260947. It seems that dtrace does something to the object files produced during the build, if the DTRACE option is enabled (which it is by default). Whatever it does, it causes these multiply defined symbols, which only appear to occur in certain (as of yet) undetermined circumstances. I would like to get the ports going again by working around these link errors, using the --allow-multiple-definition linker flag, which is supported by both GN ld and lld.
Created attachment 235556 [details] lang/perl5*: work around duplicate symbol errors with dtrace enabled
Adding some people who might know more about what dtrace is doing to those object files.
See also bug 258872.
What's the easiest way for me to reproduce this locally? I don't see an llvm15 package available.
Probably the easiest is to rebuild world with WITH_LLVM_BINUTILS=yes, as in bug 258872? Otherwise, you could get the llvm-15-update branch: git clone -b llvm-15-update https://github.com/DimitryAndric/freebsd-src.git
I got a similar sort of failure while building java/openjdk11, which apparently also has dtrace features enabled: === Output from failing command(s) repeated here === * For target hotspot_variant-server_libjvm_objs_BUILD_LIBJVM_link: c++: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument] c++: warning: argument unused during compilation: '-static-libgcc' [-Wunused-command-line-argument] ld: error: duplicate symbol: __dtrace_hotspot___monitor__notifyAll >>> defined in hotspot/variant-server/libjvm/objs/objectMonitor.o >>> defined in hotspot/variant-server/libjvm/objs/synchronizer.o ld: error: duplicate symbol: __dtrace_hotspot___monitor__notify >>> defined in hotspot/variant-server/libjvm/objs/objectMonitor.o >>> defined in hotspot/variant-server/libjvm/objs/synchronizer.o c++: error: linker command failed with exit code 1 (use -v to see invocation) E.g. again dtrace is doing something with these symbols that makes lld think they're duplicated. It looks like the object files are OK *before* dtrace touches them, though.
So until a dtrace person can figure out what the root cause of the problem is, I'm going to commit the workarounds, to unblock bug 265425.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=4ae8ff941b29191641e22a06e39ea27aa38c7848 commit 4ae8ff941b29191641e22a06e39ea27aa38c7848 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2022-09-19 18:54:14 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2022-09-19 18:54:14 +0000 lang/perl5*: work around duplicate symbol errors with lld 15 and dtrace enabled Building any of the lang/perl5* ports with clang and lld 15, and the DTRACE option enabled (which is default on) results in link errors similar to: cc -pthread -Wl,-E -fstack-protector-strong -L/usr/local/lib -o miniperl mpdtrace/opmini.o mpdtrace/perlmini.o mpdtrace/universalmini.o mpdtrace/gv.o mpdtrace/toke.o mpdtrace/perly.o mpdtrace/pad.o mpdtrace/regcomp.o mpdtrace/dump.o mpdtrace/util.o mpdtrace/mg.o mpdtrace/reentr.o mpdtrace/mro_core.o mpdtrace/keywords.o mpdtrace/builtin.o mpdtrace/hv.o mpdtrace/av.o mpdtrace/run.o mpdtrace/pp_hot.o mpdtrace/sv.o mpdtrace/pp.o mpdtrace/scope.o mpdtrace/pp_ctl.o mpdtrace/pp_sys.o mpdtrace/doop.o mpdtrace/doio.o mpdtrace/regexec.o mpdtrace/utf8.o mpdtrace/taint.o mpdtrace/deb.o mpdtrace/globals.o mpdtrace/perlio.o mpdtrace/numeric.o mpdtrace/mathoms.o mpdtrace/locale.o mpdtrace/pp_pack.o mpdtrace/pp_sort.o mpdtrace/caretx.o mpdtrace/dquote.o mpdtrace/time64.o mpdtrace/miniperlmain.o dtrace_mini.o -lpthread -lm -lcrypt -lutil ld: error: duplicate symbol: __dtraceenabled_perl___sub__entry >>> defined in mpdtrace/pp_hot.o >>> defined in mpdtrace/pp_sort.o ld: error: duplicate symbol: __dtraceenabled_perl___sub__entry >>> defined in mpdtrace/pp_hot.o >>> defined in mpdtrace/regexec.o ld: error: duplicate symbol: __dtraceenabled_perl___op__entry >>> defined in mpdtrace/perlmini.o >>> defined in mpdtrace/run.o ld: error: duplicate symbol: __dtraceenabled_perl___op__entry >>> defined in mpdtrace/perlmini.o >>> defined in mpdtrace/dump.o ld: error: duplicate symbol: __dtraceenabled_perl___sub__entry >>> defined in mpdtrace/pp_hot.o >>> defined in mpdtrace/pp_ctl.o cc: error: linker command failed with exit code 1 (use -v to see invocation) Work around these errors by allowing multiple definitions during linking, using the --allow-multiple-definition linker flag. (Note: this flag is also supported by GNU ld.) PR: 265516 Approved by: maintainer timeout (1 month) MFH: 2022Q3 lang/perl5-devel/Makefile | 2 +- lang/perl5-devel/files/patch-hints_freebsd.sh | 13 ++++++++++++- lang/perl5.32/Makefile | 2 +- lang/perl5.32/files/patch-hints_freebsd.sh | 13 ++++++++++++- lang/perl5.34/Makefile | 2 +- lang/perl5.34/files/patch-hints_freebsd.sh | 13 ++++++++++++- lang/perl5.36/Makefile | 2 +- lang/perl5.36/files/patch-hints_freebsd.sh | 13 ++++++++++++- 8 files changed, 52 insertions(+), 8 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=8c69fc20e6c71c3c5e71c8c9fcfb08ea9d5eb48d commit 8c69fc20e6c71c3c5e71c8c9fcfb08ea9d5eb48d Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2022-09-21 20:24:33 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2022-09-21 20:26:53 +0000 lang/perl5*: alternative workaround for lld 15 and dtrace enabled Modify the workaround committed in 4ae8ff941b29 by only adding -Wl,--allow-multiple-definition to the two link command lines that require it, instead of adding it to hints/freebsd.sh Otherwise, that linker flag is emitted into perl's global configuration (/usr/local/lib/perl5/5.xx/mach/Config_heavy.pl), and might be used by other ports which link in libperl, such as www/mod_perl2, which cannot correctly handle any unexpected linker flags, leading to errors. PR: 265516 Reported by: lev Approved by: maintainer timeout (1 month) Fixes: 4ae8ff941b29 MFH: 2022Q3 lang/perl5-devel/Makefile | 2 +- lang/perl5-devel/files/patch-Makefile.SH | 22 ++++++++++++++++++++-- lang/perl5-devel/files/patch-hints_freebsd.sh | 11 ----------- lang/perl5.32/Makefile | 2 +- lang/perl5.32/files/patch-Makefile.SH | 22 ++++++++++++++++++++-- lang/perl5.32/files/patch-hints_freebsd.sh | 11 ----------- lang/perl5.34/Makefile | 2 +- lang/perl5.34/files/patch-Makefile.SH | 22 ++++++++++++++++++++-- lang/perl5.34/files/patch-hints_freebsd.sh | 11 ----------- lang/perl5.36/Makefile | 2 +- lang/perl5.36/files/patch-Makefile.SH | 22 ++++++++++++++++++++-- lang/perl5.36/files/patch-hints_freebsd.sh | 11 ----------- 12 files changed, 84 insertions(+), 56 deletions(-)
I believe we'll end up modifying dtrace to avoid annoying the linker, and then these patches can be revert.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=33b05a16fc0346ecdf0206438bd9efe995339bee commit 33b05a16fc0346ecdf0206438bd9efe995339bee Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2022-12-12 13:30:34 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2022-12-12 13:34:48 +0000 lang/perl5*: remove workarounds for lld 15 and dtrace enabled After https://cgit.freebsd.org/src/commit/?id=be39466a1035, there is no need anymore to patch the perl5 Makefiles to add "-Wl,--allow-multiple-definition" to the linker flags. They should now link with lld 15 and later without any issues. PR: 265516 Fixes: 8c69fc20e6c7 MFH: 2022Q4 lang/perl5-devel/files/patch-Makefile.SH | 18 ------------------ lang/perl5.32/files/patch-Makefile.SH | 18 ------------------ lang/perl5.34/files/patch-Makefile.SH | 18 ------------------ lang/perl5.36/files/patch-Makefile.SH | 18 ------------------ 4 files changed, 72 deletions(-)