Bug 1600183 - Fixes and improvements for ARC
Summary: Fixes and improvements for ARC
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: cross-gcc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: David Howells
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-07-11 15:53 UTC by Alexey Brodkin
Modified: 2018-07-31 18:01 UTC (History)
4 users (show)

Fixed In Version: cross-gcc-8.1.1-3.fc28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-07-31 18:01:28 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Back-port support of multilib for arc-linux- targets (2.54 KB, patch)
2018-07-12 06:26 UTC, Alexey Brodkin
no flags Details | Diff
Backported fix for assembler for ARC700 (12.04 KB, patch)
2018-07-12 10:44 UTC, Alexey Brodkin
no flags Details | Diff

Description Alexey Brodkin 2018-07-11 15:53:14 UTC
1. Switch by default to ARC HS

ARC700 is old and almost obsolete family and we don't expect it to be used
in new designs while ARC HS is a new gen cores we're focused now so it really
makes sense to build GCC for ARC HS.

Even though compiler itlef might generate code equally well for whatever mcpu
we ask but libgcc only gets built for one cpu and so let's have it built for
ARC HS. That way we'll able to build Linux kernel for ARC HS - we do rely on
libgcc in Linux kernel so we need to have it built accordingly.

That's a fix:
----------------------------->8-------------------------
@@ -450,7 +450,7 @@ function config_target () {
     CONFIG_FLAGS=
     case $arch in
        arc-*)
-           CONFIG_FLAGS="--with-cpu=arc700"
+           CONFIG_FLAGS="--with-cpu=hs38"
            ;;
----------------------------->8-------------------------


2. Config target as "arc-linux-gnu"

Even though we don't have ARC port of glibc in upstream we're working ard on
that so quite soon "gnu" suffix will make sense for ARC as well.
But anyways given we don't cross-build glibc for any arch except ARM it's safe
to use arc-linux-gnu here. Moreover we configure Binutils that way and
with current cross-gcc for ARC compiler cannot find assembler, see:
----------------------------->8-------------------------
access("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/", X_OK) = 0
access("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/", X_OK) = 0
access("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/../../../../arc700-unknown-linux-uclibc/lib/arc700-unknown-linux-uclibc/8/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/../../../../arc700-unknown-linux-uclibc/lib/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/arc700-unknown-linux-uclibc/specs", R_OK) = -1 ENOENT (No such file or directory)
stat("/usr/libexec/gcc/arc700-unknown-linux-uclibc/8/cc1", {st_mode=S_IFREG|0755, st_size=15870856, ...}) = 0
access("/usr/libexec/gcc/arc700-unknown-linux-uclibc/8/cc1", X_OK) = 0
stat("/usr/libexec/gcc/arc700-unknown-linux-uclibc/8/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
stat("/usr/libexec/gcc/arc700-unknown-linux-uclibc/8/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
stat("/usr/libexec/gcc/arc700-unknown-linux-uclibc/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
stat("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
stat("/usr/lib/gcc/arc700-unknown-linux-uclibc/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
stat("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/../../../../arc700-unknown-linux-uclibc/bin/arc700-unknown-linux-uclibc/8/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
stat("/usr/lib/gcc/arc700-unknown-linux-uclibc/8/../../../../arc700-unknown-linux-uclibc/bin/as", 0x7fff40e70130) = -1 ENOENT (No such file or directory)
pipe([3, 4])                            = 0
vfork()                                 = 14072
close(4)                                = 0
vfork()                                 = 14073
close(3)                                = 0
wait4(14072, as: unrecognized option '-mcpu=arc700'
----------------------------->8-------------------------

That's what makes it work:
----------------------------->8-------------------------
@@ -426,7 +426,7 @@ function config_target () {
 
     case $arch in
        aarch64-*)      target=aarch64-linux-gnu;;
-       arc-*)          target=arc700-unknown-linux-uclibc;;
+       arc-*)          target=arc-linux-gnu;;
        arm-*)          target=arm-linux-gnueabi;;
        avr32-*)        target=avr-linux;;
        bfin-*)         target=bfin-uclinux;;
----------------------------->8-------------------------


3. Use default target_cpu in install_lang

"arc700" is not relevant any longer as stated above and if we try to use
the same target as in config_target above then we fail on .rpm building:
----------------------------->8-------------------------
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Processing files: gcc-arc-linux-gnu-8.1.1-2.fc28.x86_64
error: Directory not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/lib/gcc/hs38-*
error: File not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/libexec/gcc/hs38*/*/cc1
error: File not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/libexec/gcc/hs38*/*/collect2
error: File not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/libexec/gcc/hs38*/*/[abd-z]*
    Directory not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/lib/gcc/hs38-*
    File not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/libexec/gcc/hs38*/*/cc1
    File not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/libexec/gcc/hs38*/*/collect2
    File not found: /home/abrodkin/Downloads/tmp/rpkg/output/cross-gcc-8.1.1-2.fc28.x86_64/usr/libexec/gcc/hs38*/*/[abd-z]*
----------------------------->8-------------------------

So just keep it simple like that:
----------------------------->8-------------------------
@@ -747,7 +747,6 @@ function install_lang () {
     cpu=${arch%%%%-*}
 
     case $cpu in
-       arc)            target_cpu=arc700;;
        avr32)          target_cpu=avr;;
        bfin)           target_cpu=bfin;;
        h8300)          target_cpu=h8300;;
----------------------------->8-------------------------


With above in place I may confirm that Linux kernel for ARC HSDK board
could be built and then it wors perfectly fine:
----------------------------->8-------------------------
Linux version 4.18.0-rc3-00185-ga46348493310 (abrodkin@abrodkin-7480l) (gcc version 8.1.1 20180626 (Red Hat Cross 8.1.1-2) (GCC)) #1 SMP PREEMPT Wed Jul 11 18
Memory @ 80000000 [1024M] 
OF: fdt: Machine model: snps,hsdk
earlycon: uart8250 at MMIO32 0xf0005000 (options '115200n8')
bootconsole [uart8250] enabled
Failed to get possible-cpus from dtb, pretending all 4 cpus exist
archs-intc      : 2 priority levels (default 1) FIRQ (not used)
...
----------------------------->8-------------------------

Comment 1 David Howells 2018-07-11 20:54:23 UTC
> Even though compiler itlef might generate code equally well for whatever
> mcpu we ask but libgcc only gets built for one cpu

Ummm...  That's not actually true:

rpm -qlp ./x86_64/gcc-sh-linux-gnu-8.1.1-2.fc28.x86_64.rpm | grep libgcc
/usr/lib/gcc/sh-linux-gnu/8/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/m2/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/m2e/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/m4-nofpu/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/m4-single-only/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/m4-single/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/m4/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m2/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m2a-single/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m2a/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m2e/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m4-nofpu/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m4-single-only/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m4-single/libgcc.a
/usr/lib/gcc/sh-linux-gnu/8/mb/m4/libgcc.a

Comment 2 David Howells 2018-07-11 22:30:44 UTC
> Moreover we configure Binutils that way and with current cross-gcc for
> ARC compiler cannot find assembler, see:

Yeah - I didn't configure cross-binutils and cross-gcc for ARC with the same target...  But cross-gcc still managed to built libgcc and I'm not sure exactly how.

Comment 3 Alexey Brodkin 2018-07-12 06:25:36 UTC
I guess that's because "CONFIG_FLAGS=--with-multilib-list=" used for SH.
But for ARC we don't support "--with-multilib-list" and support of multilib for arc-linux targets was added right after 8.1.0, see https://github.com/gcc-mirror/gcc/commit/0eacfbcb2bf1834294f468a2bb41fe5d5e8d3883#diff-fb3f1781891204d8e51adc85578e9a19.

With attached arc-enable-multilib.patch we get multiple libgcc's built:
-------------------------------->8----------------------------
rpm -qlp x86_64/gcc-arc-linux-gnu-8.1.1-3.fc28.x86_64.rpm | grep libgcc
/usr/lib/gcc/arc-linux-gnu/8/arc700/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/archs/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/hs/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/hs38/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/hs38_linux/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/nps400/libgcc.a
-------------------------------->8----------------------------

Comment 4 Alexey Brodkin 2018-07-12 06:26:44 UTC
Created attachment 1458263 [details]
Back-port support of multilib for arc-linux- targets

Comment 5 David Howells 2018-07-12 06:51:41 UTC
Would you say:

--with-multilib-list=arc700,archs,hs,hs38,hs38_linux,nps400

Comment 6 Alexey Brodkin 2018-07-12 07:13:43 UTC
1. I'm not sure if "with-multilib-list" works for ARC in GCC.
   IIRC I tried that option with Crosstool-NG earlier and that made no sense.
   (Note I'm more of a user of GCC than developer thus have not that good knowledge of its internals).

2. "--enable-multilib" is set by-default and that means we'll get libs built for all supported by that gcc target ("arc-linux-" in our case) CPUs.

3. Whenever new CPUs get added in MULTILIB_OPTIONS in gcc/config/arc/t-multilib-linux we'll get corresponding libs built automatically without a need for you to change anything.

Comment 7 David Howells 2018-07-12 08:00:12 UTC
I see.  Without the multilib list, I get:

/usr/lib/gcc/arc-linux-gnu/8/arc700/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/archs/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/hs/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/hs38/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/hs38_linux/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/libgcc.a
/usr/lib/gcc/arc-linux-gnu/8/nps400/libgcc.a

Comment 8 Alexey Brodkin 2018-07-12 08:07:51 UTC
And that's exactly what we want, as these are all the CPUs mentioned in "gcc/config/arc/t-multilib-linux", see https://github.com/gcc-mirror/gcc/blob/master/gcc/config/arc/t-multilib-linux#L19.

And while at it - what's a situation with Elf32/baremetal tools in Fedora/RHEL?

Comment 9 David Howells 2018-07-12 08:27:33 UTC
(In reply to Alexey Brodkin from comment #8)
> And while at it - what's a situation with Elf32/baremetal tools in
> Fedora/RHEL?

I've no idea, I'm afraid.  I'd recommend asking on one of the fedora mailing lists or raise a BZ to add ARC support to that if you feel that it's missing.

Comment 10 Alexey Brodkin 2018-07-12 10:44:58 UTC
Created attachment 1458340 [details]
Backported fix for assembler for ARC700

This fix is required for building Linux kernel for ARC700 (ARCv2 AKA HS cores are not affected).

Comment 11 David Howells 2018-07-12 12:28:19 UTC
Can you open that as a new bz against cross-binutils?  Or is it okay to wait till binutils-2.31 comes out?

Comment 12 Alexey Brodkin 2018-07-12 13:06:32 UTC
Well maybe the name is a bit incorrect but that's the patch for GCC not binutils.
It's compiler which generates improper meta-data that assembler cannot encode into instructions.

Comment 13 David Howells 2018-07-12 13:30:40 UTC
Ah, sorry - you said it was a fix for the assembler.

Comment 14 Fedora Update System 2018-07-13 08:56:40 UTC
cross-gcc-8.1.1-3.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-9a0d2245d5

Comment 15 Fedora Update System 2018-07-16 20:29:03 UTC
cross-gcc-8.1.1-3.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-9a0d2245d5

Comment 16 Fedora Update System 2018-07-31 18:01:28 UTC
cross-gcc-8.1.1-3.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.