Page MenuHomeFreeBSD

Start of arm64 toolchain support (sufficient for kernel-toolchain)
ClosedPublic

Authored by emaste on Mar 4 2015, 3:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 19, 4:33 AM
Unknown Object (File)
Tue, Mar 19, 2:43 AM
Unknown Object (File)
Feb 23 2024, 4:45 PM
Unknown Object (File)
Feb 15 2024, 9:12 PM
Unknown Object (File)
Jan 26 2024, 11:58 AM
Unknown Object (File)
Jan 26 2024, 11:58 AM
Unknown Object (File)
Jan 26 2024, 11:54 AM
Unknown Object (File)
Jan 26 2024, 11:54 AM
Subscribers

Details

Reviewers
emaste
andrew
imp
Summary

This is sufficient for make TARGET=arm64 kernel-toolchain. It relies on having the aarch64-binutils port or package installed.

See https://wiki.freebsd.org/arm64 for more information.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste retitled this revision from to Start of arm64 toolchain support (sufficient for kernel-toolchain).
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added a subscriber: Unknown Object (MLST).Mar 4 2015, 1:36 PM
andrew added inline comments.
Makefile.inc1
326

Should we add a check here and warn or error out if the package is missing?

emaste added inline comments.
Makefile.inc1
326

I originally had a test that CROSS_BINUTILS_PREFIX exists, but @imp pointed out that it's also possible to use a per-file prefix, not a path prefix.

I suppose we should change the test to also check for empty CROSS_BINUTILS_PREFIX, and test directory existence in that case.

Not quite ready for prime time, and adds extra warts to the build system that don't need to be added to it.

Makefile.inc1
325

This is ugly. Why is aarch64 special? Why wouldn't we need it for sparc64 if we removed ld and gcc? I really don't like this at all.

I know it is here for convenience, but there's got to be a more generic way to do it.

share/mk/bsd.endian.mk
6

This shouldn't reference MACHINE. I should fix that.

share/mk/src.opts.mk
236–241

This is wrong on a number of levels.

We generally opt-out of binaries in the .mk files.
It allows people to set them to 'yes' even though it can't possibly work.

We really need an "__ALWAYS_NO" which could be set based on what
arch you are on. I can add that. binuitls might be that specail.

gdb certainly isn't.

Makefile.inc1
325

Why wouldn't we need it for sparc64 if we removed ld and gcc?

We would. I was originally planning require users to set CROSS_BINUTILS_PREFIX in order to make use of this, but Andy wanted it to be automatic.

Do you have a sketch of something that would be a more generic way to do it?

share/mk/src.opts.mk
236–241

I don't fully understand your comment here - if I understand correctly you're saying we should forcibly disable options that can't work on a given platform, not just disable them by default.

Both binutils and gdb are the same in that regard at least, they both lack aarch64 support.

In D2005#9, @emaste wrote:

I don't fully understand your comment here - if I understand correctly you're saying we should forcibly disable options that can't work on a given platform, not just disable them by default.

Yes. that's what we do in the rest of the tree, in a variety of stupid ways.

Both binutils and gdb are the same in that regard at least, they both lack aarch64 support.

binutils is a bootstrap. gdb isn't. that's how they are different. But both could likely use the forced off solution.

I really *HATE* options that are different based on the platform. They cause nothing but problems. Every single time. I'd like to find a better way to cope.

Perhaps something like

-.if defined(WITHOUT_${var})                    # WITHOUT always wins
+# WITHOUT and __FORCE_NO always win
+.if defined(WITHOUT_${var}) || defined(__FORCE_NO_${var}

along with

+__FORCE_NO_GDB=true
+__FORCE_NO_BINUTILS=true
+__FORCE_NO_BINUTILS_BOOTSTRAP=true

for arm64

Makefile.inc1
325

I'm not entirely sure. Let me think about that one.

share/mk/src.opts.mk
236–241

.if ${T} == "aarch64"
ALWAYS_NO+= BINUTILS BINUTILS_BOOTSTRAP GDB
.endif

Makefile.inc1
325

We can change the test to BINUTILS_BOOTSTRAP in __ALWAYS_NO instead. It seems reasonable that those cases where we force it off ought to have the default.

Something similar to

# If we do not have a bootstrap binutils (because the in-tree one does not    
# support the target architecture), provide a default cross-binutils prefix.  
# This allows aarch64 builds, for example, to automatically use the
# aarch64-binutils port or package.
.if !empty(__ALWAYS_NO:MBINUTILS_BOOTSTRAP) && !defined(CROSS_BINUTILS_PREFIX) 
CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
.if !exists(${CROSS_BINUTILS_PREFIX})
.error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
.endif
.endif
Makefile.inc1
325

I like this notion. That's acceptable to me.

share/mk/src.opts.mk
236–241

See https://reviews.freebsd.org/D2009 for the changes I've had in my tree. I'll get them in quickly.

emaste edited edge metadata.

Rebased and incorporated changes that have gone into HEAD (e.g. BROKEN_OPTIONS)

usr.bin/xlint/arch/arm64/targparam.h
1 ↗(On Diff #4099)

I will import the NetBSD aarch64 version of this file instead; it already includes a change to the 2-clause license.

usr.bin/xlint/lint1/param.h
98

not actually necessary, as it is picked up from targparam.h. (Note that there is no powerpc64 definition, for instance.)

usr.bin/xlint/lint1/param.h
98

The #elif __aarch64__ is needed to stop the below #error unknown machine type.

From my reading of the gcc source we define both __powerpc__ and __powerpc64__ on powerpc64 so will be caught by the __powerpc__ case above, this is not the case on arm64.

emaste edited reviewers, added: imp, andrew; removed: bdrewery.
emaste removed subscribers: imp, andrew, Unknown Object (MLST).

Replace crt1.c with one based on amd64
This also cleanus up:

  • Remove __ps_strings, it's not being used, we get this from sysctl
  • Remove the elf note, we only need it on arm for pkg

Use aarch64 for userland paths for consistency with uname -p and NetBSD

lib/csu/aarch64/crt1.c
3

Should add another copyright line for the new work

usr.bin/xlint/lint1/param.h
98

This file is actually not used.

emaste added a reviewer: emaste.
This revision is now accepted and ready to land.Mar 19 2015, 3:57 PM