Page MenuHomeFreeBSD

RISC-V kernel-toolchain
ClosedPublic

Authored by br on Dec 8 2015, 6:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 13 2024, 9:31 PM
Unknown Object (File)
Mar 8 2024, 1:15 AM
Unknown Object (File)
Feb 9 2024, 9:34 PM
Unknown Object (File)
Feb 5 2024, 1:46 AM
Unknown Object (File)
Feb 3 2024, 11:50 AM
Unknown Object (File)
Jan 26 2024, 9:28 PM
Unknown Object (File)
Jan 26 2024, 5:34 AM
Unknown Object (File)
Jan 26 2024, 5:34 AM
Subscribers

Details

Summary

Minimal set of changes required for "make kernel-toolchain" for RISC-V

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

br retitled this revision from to RISC-V kernel-toolchain.
br updated this object.
br edited the test plan for this revision. (Show Details)
br added reviewers: imp, andrew, emaste.
Makefile.inc1
175 ↗(On Diff #10931)

We should probably wrap this line (in a separate commit prior to this change), it's already very long.

etc/etc.riscv/ttys
1–4 ↗(On Diff #10931)

Probably a candidate for https://wiki.freebsd.org/SrcDeDup

lib/csu/riscv/crt1.c
40–42 ↗(On Diff #10931)

Remove this - see rS282551 / D2422. The other csu files should be done as well.

Remove historical GNUC test

The requirement is for a GCC-compatible compiler and not necessarily
GCC itself. However, we currently expect any compiler used for building    
the whole of FreeBSD to be GCC-compatible and many things will break if    
not; there's no longer a need to have an explicit test for this in rtld.
lib/csu/riscv/crti.S
5 ↗(On Diff #10931)

These should probably be "Portions of this software were..." when there are two entries

share/mk/src.opts.mk
237–239 ↗(On Diff #10931)

Perhaps we should list these on individual lines with a comment about why they fail, something like

BROKEN_OPTIONS+=PROFILE # missing mumble
BROKEN_OPTIONS+=RESCUE # crunchgen does not support RISC-V
bdrewery requested changes to this revision.Dec 8 2015, 7:03 PM
bdrewery added a reviewer: bdrewery.
bdrewery added inline comments.
Makefile.inc1
175 ↗(On Diff #10932)

Please also update the TARGET_ARCHES list in share/mk/local.meta.sys.mk

lib/csu/riscv/Makefile
40–42 ↗(On Diff #10932)

Please see the other csu directories. We're using FILES* now. Like this:

FILES= ${OBJS}
FILESMODE= ${LIBMODE}
FILESOWN= ${LIBOWN}
FILESGRP= ${LIBGRP}
FILESDIR= ${LIBDIR}

These FILES qualify as libraries for the purpose of LIBRARIES_ONLY.

.undef LIBRARIES_ONLY

This revision now requires changes to proceed.Dec 8 2015, 7:03 PM
etc/etc.riscv/ttys
44–51 ↗(On Diff #10931)

You might want to update this, we have moved to use 3wire and onifconsole on these.

lib/csu/riscv/crt1.c
1 ↗(On Diff #10931)

This file looks very similar to the arm64 version (it even has the _end hack). You should be using the existing license & adding yourself to it. The alternative is to redo it based on the amd64 version (which is similar).

lib/libc/riscv/Makefile.inc
3 ↗(On Diff #10931)

arm?

lib/msun/riscv/Makefile.inc
3 ↗(On Diff #10931)

What size is long double? On arm64 this is 113 as it's a 128-bit type.

lib/msun/riscv/fenv.h
1 ↗(On Diff #10931)

This looks very similar to the arm64 fenv.h, the license may need to be checked.

lib/csu/riscv/crt1.c
41–43 ↗(On Diff #10932)

Other csu files addressed in rS292000

lib/msun/riscv/fenv.h
2 ↗(On Diff #10932)

Sometimes I think we need to have a fp-ieee directory that has all this stuff in it that most ports these days just reference (or define one or two things to describe the flavor, then include).
Back when there were many types of floating point, the structure we had made sense. But once the Alpha adopted IEEE floating point, VAX format died in the wild and people only have done IEEE FP since then.

Of course, that may be too big an ask for someone porting to a new arch since we've not required it for others.

share/mk/bsd.cpu.mk
148 ↗(On Diff #10932)

Before this you need something like
. elif ${MACHINE_CPUARCH} == "riscv"
_CPUFLAGS = -march=${CPUTYPE}
.endif

or maybe -mcpu depending on what gcc does.

I see references to riscv32 and riscv64 so maybe we need that distinction too? What did you do your port for?

156 ↗(On Diff #10932)

this should have been added alphabetically.

277 ↗(On Diff #10932)

You need to minimally have here

. elif ${MACHINE_ARCH} == "riscv"
MACHINE_CPU = riscv

here too. There's two places for each architecture we set it.

313 ↗(On Diff #10932)

This isn't the compiler default?

share/mk/bsd.sys.mk
113 ↗(On Diff #10932)

is this a riscv thing, or is it just a gcc 5.2.0 thing?

I'm not entirely sure this is the right place for this as well, but let's sort that bit out first.

share/mk/src.opts.mk
237–239 ↗(On Diff #10932)

I'm curious why CXX is on the list too...

lib/msun/riscv/fenv.h
2 ↗(On Diff #10932)

I think it's reasonable to move ahead with this as is but ensure it's documented on the SrcDeDup wiki page and come back and address them later on.

share/mk/bsd.cpu.mk
156 ↗(On Diff #10932)

yep, we should move it in a separate commit prior to D4445 going in

lib/msun/riscv/fenv.h
2 ↗(On Diff #10932)

I'd settle for 'update SrcDeDup wiki' here.

share/mk/bsd.cpu.mk
156 ↗(On Diff #10932)

Agreed. I was mostly grumpy since I thought I'd alphabetized these already. Turns out that mips is after powerpc, so my world was shattered again there. Let's actually move it after riscv goes in. It isn't important enough to force a rebase / merge cycle.

share/mk/bsd.cpu.mk
156 ↗(On Diff #10932)

I've already forced a rebase cycle though :) I think Ruslan expected at least one iteration anyway.

My general approach has been to put it in the correct spot if it's already ordered or only one is out of place, or at the end otherwise.

br edited edge metadata.
bdrewery edited edge metadata.

Thanks, my findings look OK now. Approving just what I've commented on. I didn't look at other pieces.

This revision is now accepted and ready to land.Dec 10 2015, 6:30 PM
share/mk/bsd.sys.mk
113 ↗(On Diff #11046)

I think it is GCC 5.2.0

Makefile
350 ↗(On Diff #11046)

Will universe work if the riscv toolchain is missing? We check for the external parts on arm64 & warn the user it was skipped.

lib/libc/riscv/Makefile.inc
1 ↗(On Diff #11046)

The libc changes are incomplete, would it pay to drop them for now so we can review them as a complete unit.

share/mk/src.opts.mk
241 ↗(On Diff #11046)

Where in the build is contents.ms from?

242 ↗(On Diff #11046)

I'm guessing we just need to add EM_RISCV to usr.sbin/crunch/crunchide/exec_elf32.c.

br edited edge metadata.
This revision now requires review to proceed.Dec 11 2015, 11:24 AM
Makefile
350 ↗(On Diff #11101)

Will not work, let remove from UNIVERSE at this step

share/mk/src.opts.mk
241 ↗(On Diff #11101)

Actually error is like that:
"libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'"

242 ↗(On Diff #11101)

yes, that works, thanks!

emaste edited edge metadata.
emaste added inline comments.
Makefile
350 ↗(On Diff #11101)

Agreed.

lib/msun/riscv/fenv.h
3 ↗(On Diff #11046)

I've added the files noted in this review to SrcDeDup

share/mk/src.opts.mk
241 ↗(On Diff #11101)

This will be taken care of with a forthcoming llvm-libunwind import
You can see WIP here: https://github.com/emaste/freebsd/commits/arm64-llvm-libunwind

242 ↗(On Diff #11101)

It turns out I had that change sitting in an old work branch but did not have a way to test -- I've committed it now.

This revision is now accepted and ready to land.Dec 11 2015, 2:10 PM
lib/msun/riscv/fenv.h
55 ↗(On Diff #11101)

These are in the wrong order

62–65 ↗(On Diff #11101)

These should be the values as applied directly to the register, e.g.

#define FE_UPWARD (3 << 5)
83–85 ↗(On Diff #11101)

This looks wrong, bits 31:8 should be zero.

share/mk/bsd.cpu.mk
155 ↗(On Diff #11101)

You can't have this as _CPUFLAGS. It is an ABI affecting flag, so must be added directly to CFLAGS.
This line should instead read something like

_CPUCFLAGS = -march=$CPUTYPE

since that generally doesn't affect the ABI, just the set of instructions used and their relative costs for the optimizer. -msoft-float, however, changes calling conventions (at least on ARM it does), so must either be the compiler default (preferred) or always added to the command line (second best). There's a spot further down in the file that does this.

share/mk/bsd.endian.mk
7 ↗(On Diff #11101)

I'd be tempted to use MACHINE_CPUARCH here, since all members of the family are little endian, right?

share/mk/bsd.sys.mk
113 ↗(On Diff #11101)

If so, it should be based on compiler version only, not on cpu arch.

br edited edge metadata.

fenv.h changed

This revision now requires review to proceed.Dec 11 2015, 2:58 PM
lib/msun/riscv/fenv.h
63 ↗(On Diff #11125)

This should be (0x03 << 5)

65 ↗(On Diff #11125)

This should be (0x01 << 5)

share/mk/bsd.cpu.mk
155 ↗(On Diff #11101)

I would expect we would move to the hard-float ABI when the kernel supports this, however we are currently missing the kernel bits.

br edited edge metadata.

mk fixed

andrew edited edge metadata.
This revision is now accepted and ready to land.Dec 11 2015, 4:08 PM
This revision was automatically updated to reflect the committed changes.