ccl icon indicating copy to clipboard operation
ccl copied to clipboard

lisp kernel build failure on FreeBSD 12.1

Open xrme opened this issue 5 years ago • 9 comments

A user reported the following build error on a FreeBSD 12.1 system:

cc -m64 -g -fuse-ld=bfd -Wl,--export-dynamic    -o ../../fx86cl64  pad.o x86-spjump64.o x86-spentry64.o x86-subprims64.o pmcl-kernel.o gc-common.o  x86-gc.o bits.o  x86-exceptions.o  x86-utils.o  image.o thread_manager.o lisp-debug.o memory.o unix-calls.o x86-asmutils64.o  imports.o lispdcmd.o plprint.o plsym.o xlbt.o x86_print.o -lm -lthr
cc: error: invalid linker name in argument '-fuse-ld=bfd'
*** Error code 1

This is vexing because the solution for #173 was to add the -fuse-ld=bfd flag. Perhaps the older bfd linker needs to be installed separately?

xrme avatar Dec 31 '19 23:12 xrme

I am in the middle of upgrading a 12.0-RELEASE system to 12.1-RELEASE, and as part of the upgrade, /usr/bin/ld.bfd is getting removed.

xrme avatar Dec 31 '19 23:12 xrme

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219717

xrme avatar Jan 01 '20 00:01 xrme

So, at the moment, we're back to

ld: error: x86-subprims64.o: SHF_MERGE section size must be a multiple of sh_entsize

which is what we saw back in #173.

xrme avatar Jan 01 '20 00:01 xrme

A question: are all the .stab* directives generated in those assembler files actually doing anything useful? All the other object files seem to have DWARF debug sections (I think) instead.

(The lld error message is misleading: it's checking section size against sh_entsize for all sections, not just SHF_MERGE sections. The .stab sections of most of the assembler-generated .o files have sizes not multiples of sh_entsize.)

RhodiumToad avatar Mar 28 '20 05:03 RhodiumToad

That’s my main question too; no longer generating .stab* directives would enable the macOS build to switch off the archaic assembler as well.

eschaton avatar Mar 28 '20 20:03 eschaton

Oh, and as I just mentioned on IRC, adding -Wl,-O0 disables merging in lld which avoids the issue entirely, so that may be an acceptable workaround.

RhodiumToad avatar Mar 30 '20 02:03 RhodiumToad

Can someone upload an lld reproduce file somewhere?

Either LLD_REPRODUCE=/tmp/rep.tar or -Wl,--reproduce=/tmp/rep.tar

The ELF specification says:

sh_entsize: Some sections hold a table of fixed-size entries, such as a symbol table. For such a section, this member gives the size in bytes of each entry. The member contains 0 if the section does not hold a table of fixed-size entries.

So it is wrong if sh_size%sh_entsize!=0

MaskRay avatar Apr 02 '20 04:04 MaskRay

@MaskRay I uploaded https://ccl.clozure.com/~rme/rep.tar.gz

xrme avatar Apr 03 '20 01:04 xrme

It can be reproduced by just using as --gstabs on a trivial assembler file and trying to link it, so it's not caused by anything specifically wrong here.

LLD bug report is https://bugs.llvm.org/show_bug.cgi?id=45370 which contains a trivial reproducer.

RhodiumToad avatar Apr 03 '20 04:04 RhodiumToad

FreeBSD 12.4 (at least) includes the fix for this. In the CCL 1.12.2 release, I've removed the -Wl,-O0 workaround (and stopped generating .stabs as well).

xrme avatar Aug 09 '23 19:08 xrme