Page MenuHomeFreeBSD

Ensure cross assembler, linker and objcopy are used for the build32 stage
ClosedPublic

Authored by dim on Mar 31 2015, 8:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 22 2024, 11:54 PM
Unknown Object (File)
Dec 31 2023, 9:31 AM
Unknown Object (File)
Dec 31 2023, 9:31 AM
Unknown Object (File)
Dec 23 2023, 5:50 AM
Unknown Object (File)
Dec 10 2023, 5:38 PM
Unknown Object (File)
Dec 9 2023, 6:08 PM
Unknown Object (File)
Dec 9 2023, 2:35 PM
Unknown Object (File)
Dec 9 2023, 12:59 PM

Details

Summary

When I tried replicating Craig Rodrigues's efforts at building head
with the amd64-xtoolchain-gcc package, I noticed that during the build32
stage it still uses the base system ld and objcopy:

[...]
--- lib/csu/i386-elf__L ---
ld -m elf_i386_fbsd -Y P,/usr/obj/home/dim/head/lib32/usr/lib32  -o crt1.o -r crt1_s.o crt1_c.o
[...]
--- lib/csu/i386-elf__L ---
objcopy --localize-symbol _start1 crt1.o
[...]
--- lib/csu/i386-elf__L ---
ld -m elf_i386_fbsd -Y P,/usr/obj/home/dim/head/lib32/usr/lib32  -o Scrt1.o -r crt1_s.o Scrt1_c.o
[...]
--- lib/csu/i386-elf__L ---
objcopy --localize-symbol _start1 Scrt1.o

And a bunch more of those. I went through the various Makefiles I could
find, replacing literal 'objcopy' with ${OBJCOPY}, which fixes the case
for objcopy.

Also, I changed LD=${LD} and AS=${AS} to use their X variants in the
definition of LIB32WMAKEFLAGS in Makefile.inc1, and added
OBJCOPY=${XOBJCOPY} to the list.

Together, these changes should ensure that the cross tools are always
used instead of the base system tools.

Test Plan

A make universe is probably required, at least.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dim retitled this revision from to Ensure cross assembler, linker and objcopy are used for the build32 stage.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: imp, bapt, rodrigc.
dim added a subscriber: Unknown Object (MLST).
Makefile.inc1
416 ↗(On Diff #4554)

You should probably test if XAS if defined: something like AS=${XAS:U${AS}} and so on

426 ↗(On Diff #4554)

Same apply here

Makefile.inc1
416 ↗(On Diff #4554)

These are also unconditionally used in the previous block for WMAKENV, e.g.:

WMAKEENV+=      CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
                DEPFLAGS="${DEPFLAGS}" \
                CPP="${XCPP} ${XCFLAGS}" \
                AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
                OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
                RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
                SIZE="${XSIZE}"

and just before that, they are unconditionally defined:

XCOMPILERS=     CC CXX CPP
.for COMPILER in ${XCOMPILERS}
.if defined(CROSS_COMPILER_PREFIX)
X${COMPILER}?=  ${CROSS_COMPILER_PREFIX}${${COMPILER}}
.else
X${COMPILER}?=  ${${COMPILER}}
.endif
.endfor
XBINUTILS=      AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
.for BINUTIL in ${XBINUTILS}
.if defined(CROSS_BINUTILS_PREFIX)
X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
.else
X${BINUTIL}?=   ${${BINUTIL}}
.endif
.endfor

So I think it is unnecessary to check them again.

bapt edited edge metadata.

yup you are right

This looks ok for me I still would be more confident with @imp reviewing as well :)

This revision is now accepted and ready to land.Mar 31 2015, 9:19 PM
In D2187#7, @bapt wrote:

yup you are right

This looks ok for me I still would be more confident with @imp reviewing as well :)

Using Xfoo unconditionally is good.

Where is OBJCOPY defined?

Makefile.inc1
416 ↗(On Diff #4554)

Do we need a similar change for powerpc?

Using Xfoo unconditionally is cool.

emaste added a reviewer: emaste.
emaste added a subscriber: emaste.

Agreed it would be nice to have @imp sign off, but looks good to me.

In D2187#11, @imp wrote:

Where is OBJCOPY defined?

In share/mk/sys.mk, as long as if !defined(%POSIX)

imp edited edge metadata.
Makefile.inc1
416 ↗(On Diff #4554)

I just looked for the LD="${LD}" assignments, and replaced them all. Maybe, for consistency, we should add OBJCOPY=${XOBJCOPY} for the powerpc case too, but I'm not sure if it's used at all in the powerpc build...

rodrigc edited edge metadata.
Makefile.inc1
416 ↗(On Diff #4554)

The OBJCOPY was more my concern. Why do we need it for i386 on amd64 and nor for powerpc on powerpc64?

Makefile.inc1
416 ↗(On Diff #4554)

objcopy is used if you generate standalone debug.

dim edited edge metadata.

Add XOBJCOPY for powerpc too.

This revision now requires review to proceed.Apr 1 2015, 5:59 PM
emaste edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 1 2015, 6:01 PM
Makefile.inc1
427 ↗(On Diff #4577)

Btw, I'm not sure about AS here, since it might not even be used in the 32 bit stage, and also I'm not sure of the syntax. Is it -a32?

dim updated this revision to Diff 4593.

Closed by commit rS280980 (authored by @dim).