public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V
@ 2022-01-02 11:20 bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 11:22 ` [Bug go/103889] " bau2wux4sh at pkv73 dot anonbox.net
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 11:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

            Bug ID: 103889
           Summary: gccgo is unable to find its standard library by
                    default on 64-Bit RISC-V
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
          Assignee: ian at airs dot com
          Reporter: bau2wux4sh at pkv73 dot anonbox.net
                CC: cmang at google dot com
  Target Milestone: ---

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 11:22 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 11:45 ` schwab@linux-m68k.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 11:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #1 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
[Hm, somehow bugzilla didn't add the description? Adding it again here.]

When compiling GCC with --disable-multilib on 64-Bit RISC-V (RV64), the gccgo
frontend does not seem to be able to find it's standard library:

        $ gccgo -v -o hello_world hello_world.go
        Using built-in specs.
        COLLECT_GCC=/usr/bin/gccgo
       
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-alpine-linux-musl/11.2.1/lto-wrapper
        Target: riscv64-alpine-linux-musl
        Configured with:
/home/buildozer/aports/main/gcc/src/gcc-11.2.1_git20211128/configure
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--build=riscv64-alpine-linux-musl --host=riscv64-alpine-linux-musl
--target=riscv64-alpine-linux-musl --with-pkgversion='Alpine
11.2.1_git20211128' --enable-checking=release --disable-fixed-point
--disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror
--disable-symvers --enable-__cxa_atexit --enable-default-pie
--enable-default-ssp --enable-cloog-backend
--enable-languages=c,c++,objc,go,fortran,jit --with-arch=rv64gc
--with-abi=lp64d --enable-autolink-libatomic --disable-libquadmath
--disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer
--enable-shared --enable-threads --enable-tls --disable-libitm
--enable-host-shared --with-system-zlib --with-linker-hash-style=gnu
        Thread model: posix
        Supported LTO compression algorithms: zlib
        gcc version 11.2.1 20211128 (Alpine 11.2.1_git20211128)
        COLLECT_GCC_OPTIONS='-g1' '-v' '-o' 'hello_world' '-shared-libgcc'
'-march=rv64gc' '-mabi=lp64d' '-march=rv64imafdc'
         /usr/libexec/gcc/riscv64-alpine-linux-musl/11.2.1/go1 hello_world.go
-quiet -dumpbase hello_world.go -dumpbase-ext .go -march=rv64gc -mabi=lp64d
-march=rv64imafdc -g1 -version -L/usr/lib/gcc/riscv64-alpine-linux-musl/11.2.1
-L/usr/lib/gcc/riscv64-alpine-linux-musl/11.2.1/../../../../riscv64-alpine-linux-musl/lib
-o /tmp/ccLBoAel.s
        GNU Go (Alpine 11.2.1_git20211128) version 11.2.1 20211128
(riscv64-alpine-linux-musl)
                compiled by GNU C version 11.2.1 20211128, GMP version 6.2.1,
MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.22-GMP

        GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072
        GNU Go (Alpine 11.2.1_git20211128) version 11.2.1 20211128
(riscv64-alpine-linux-musl)
                compiled by GNU C version 11.2.1 20211128, GMP version 6.2.1,
MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.22-GMP

        GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072
        hello_world.go:3:11: error: import file 'fmt' not found
            3 | import "fmt"
              |           ^
        hello_world.go:6:9: error: reference to undefined name 'fmt'
            6 |         fmt.Println("Hello, World!")
              |         ^

However, compiling on x86_64 works as expected:

        $ gccgo -v -o hello_world hello_world.go
        Using built-in specs.
        COLLECT_GCC=gccgo
       
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/lto-wrapper
        Target: x86_64-alpine-linux-musl
        Configured with:
/home/buildozer/aports/main/gcc/src/gcc-11.2.1_git20211128/configure
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl
--target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 11.2.1_git20211128'
--enable-checking=release --disable-fixed-point --disable-libstdcxx-pch
--disable-multilib --disable-nls --disable-werror --disable-symvers
--enable-__cxa_atexit --enable-default-pie --enable-default-ssp
--enable-cloog-backend --enable-languages=c,c++,d,objc,go,fortran,ada,jit
--disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer
--enable-shared --enable-threads --enable-tls --enable-host-shared
--with-system-zlib --with-linker-hash-style=gnu
        Thread model: posix
        Supported LTO compression algorithms: zlib
        gcc version 11.2.1 20211128 (Alpine 11.2.1_git20211128)
        COLLECT_GCC_OPTIONS='-g1' '-v' '-o' 'hello_world' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
         /usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/go1 hello_world.go
-quiet -dumpbase hello_world.go -dumpbase-ext .go -mtune=generic -march=x86-64
-g1 -version -L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib -L/lib/../lib
-L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../.. -o /tmp/ccjMeGOf.s
        GNU Go (Alpine 11.2.1_git20211128) version 11.2.1 20211128
(x86_64-alpine-linux-musl)
                compiled by GNU C version 11.2.1 20211128, GMP version 6.2.1,
MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.22-GMP

        GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072
        GNU Go (Alpine 11.2.1_git20211128) version 11.2.1 20211128
(x86_64-alpine-linux-musl)
                compiled by GNU C version 11.2.1 20211128, GMP version 6.2.1,
MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.22-GMP

        GGC heuristics: --param ggc-min-expand=100 --param
ggc-min-heapsize=131072
        COLLECT_GCC_OPTIONS='-g1' '-v' '-o' 'hello_world' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
        
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/as
-v --gdwarf-5 --64 -o /tmp/ccKNJKMa.o /tmp/ccjMeGOf.s
        GNU assembler version 2.37 (x86_64-alpine-linux-musl) using BFD version
(GNU Binutils) 2.37
       
COMPILER_PATH=/usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/:/usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/:/usr/libexec/gcc/x86_64-alpine-linux-musl/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/
       
LIBRARY_PATH=/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../:/lib/:/usr/lib/
        COLLECT_GCC_OPTIONS='-g1' '-v' '-o' 'hello_world' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'hello_world.'
         /usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/collect2 -plugin
/usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/liblto_plugin.so
-plugin-opt=/usr/libexec/gcc/x86_64-alpine-linux-musl/11.2.1/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccDpLAAf.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
--eh-frame-hdr --hash-style=gnu -m elf_x86_64 --as-needed -dynamic-linker
/lib/ld-musl-x86_64.so.1 -pie -z relro -z now -o hello_world
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/Scrt1.o
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/crti.o
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/crtbeginS.o
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib -L/lib/../lib
-L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../.. /tmp/ccKNJKMa.o
-lgobegin -lgo -lm -lssp_nonshared -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/crtendS.o
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/crtn.o
        COLLECT_GCC_OPTIONS='-g1' '-v' '-o' 'hello_world' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'hello_world.'

By comparing the two verbose outputs, it seems that the some -L arguments
passed to the x86_64 version area not passed to the riscv64 version of the
gccgo compiler. Most notably,
-L/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib (which is a
relative path to /usr/lib) is missing in the riscv64 invocation. This missing
search path seems to be the root cause of the issue as invoking gccgo on
riscv64 as `gccgo -L/usr/lib -o hello_world hello_world.go` works as expected.

I am not sure why this search path is missing on riscv64. Any guidance on
debugging this further would be appreciated.

As one can see in the output above, I am using Alpine's GCC version which
includes a few patches for gccgo since the vanilla gccgo version does not work
with musl libc by default. These patches are currently in the process of being
upstreamed and riscv64 is the only architecture where gccgo doesn't work
out-of-the-box at the moment (x86_64, x86, ppc64le, armhf, armv7, and aarch64
work fine).

The patches can be found here: https://git.alpinelinux.org/aports/tree/main/gcc

My current hypothesis is that this might be related to the `gcc
-print-multi-os-directory` output. On x86_64 this outputs `../lib` and on
riscv64 it simply outputs `.`.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 11:22 ` [Bug go/103889] " bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 11:45 ` schwab@linux-m68k.org
  2022-01-02 11:48 ` bau2wux4sh at pkv73 dot anonbox.net
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: schwab@linux-m68k.org @ 2022-01-02 11:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
Probably specific to musl.  Worksforme on openSUSE.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 11:22 ` [Bug go/103889] " bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 11:45 ` schwab@linux-m68k.org
@ 2022-01-02 11:48 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 12:15 ` schwab@linux-m68k.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 11:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #3 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
(In reply to Andreas Schwab from comment #2)
> Probably specific to musl.  Worksforme on openSUSE.

Might be. Are you also compiling GCC with --disable-multilib on RV64? What's
your output of `gcc -print-multi-os-directory` on RV64?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (2 preceding siblings ...)
  2022-01-02 11:48 ` bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 12:15 ` schwab@linux-m68k.org
  2022-01-02 12:52 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: schwab@linux-m68k.org @ 2022-01-02 12:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
$ gccgo hellogo.go -o hellogo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/riscv64-suse-linux/11/lto-wrapper
Target: riscv64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d,jit --enable-host-shared
--enable-checking=release --disable-werror
--with-gxx-include-dir=/usr/include/c++/11 --enable-ssp --disable-libssp
--disable-libvtv --enable-cet=auto --disable-libcc1 --enable-plugin
--with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --enable-libphobos
--enable-version-specific-runtime-libs --with-gcc-major-version-only
--enable-linker-build-id --enable-linux-futex --program-suffix=-11
--without-system-libunwind --disable-multilib --enable-link-mutex
--build=riscv64-suse-linux --host=riscv64-suse-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20211124 [revision 7510c23c1ec53aa4a62705f0384079661342ff7b]
(SUSE Linux) 
COLLECT_GCC_OPTIONS='-g1' '-o' 'hellogo' '-v' '-shared-libgcc' '-march=rv64gc'
'-mabi=lp64d' '-march=rv64imafdc'
 /usr/lib64/gcc/riscv64-suse-linux/11/go1 hellogo.go -quiet -dumpbase
hellogo.go -dumpbase-ext .go -march=rv64gc -mabi=lp64d -march=rv64imafdc -g1
-version -L/usr/lib64/gcc/riscv64-suse-linux/11
-L/usr/lib64/gcc/riscv64-suse-linux/11/../../../../riscv64-suse-linux/lib
-L/lib64/lp64d -L/usr/lib64/lp64d -o /tmp/cckzhr7m.s
GNU Go (SUSE Linux) version 11.2.1 20211124 [revision
7510c23c1ec53aa4a62705f0384079661342ff7b] (riscv64-suse-linux)
        compiled by GNU C version 11.2.1 20211124 [revision
7510c23c1ec53aa4a62705f0384079661342ff7b], GMP version 6.2.1, MPFR version
4.1.0-p7, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Go (SUSE Linux) version 11.2.1 20211124 [revision
7510c23c1ec53aa4a62705f0384079661342ff7b] (riscv64-suse-linux)
        compiled by GNU C version 11.2.1 20211124 [revision
7510c23c1ec53aa4a62705f0384079661342ff7b], GMP version 6.2.1, MPFR version
4.1.0-p7, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-g1' '-o' 'hellogo' '-v' '-shared-libgcc' '-march=rv64gc'
'-mabi=lp64d' '-march=rv64imafdc'
 /usr/lib64/gcc/riscv64-suse-linux/11/../../../../riscv64-suse-linux/bin/as -v
--gdwarf-5 --traditional-format -march=rv64gc -march=rv64imafdc -mabi=lp64d -o
/tmp/cc1upFah.o /tmp/cckzhr7m.s
GNU assembler version 2.37 (riscv64-suse-linux) using BFD version (GNU
Binutils; openSUSE Tumbleweed) 2.37.20211112-3
COMPILER_PATH=/usr/lib64/gcc/riscv64-suse-linux/11/:/usr/lib64/gcc/riscv64-suse-linux/11/:/usr/lib64/gcc/riscv64-suse-linux/:/usr/lib64/gcc/riscv64-suse-linux/11/:/usr/lib64/gcc/riscv64-suse-linux/:/usr/lib64/gcc/riscv64-suse-linux/11/../../../../riscv64-suse-linux/bin/
LIBRARY_PATH=/usr/lib64/gcc/riscv64-suse-linux/11/:/usr/lib64/gcc/riscv64-suse-linux/11/../../../../riscv64-suse-linux/lib/:/lib64/lp64d/:/usr/lib64/lp64d/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g1' '-o' 'hellogo' '-v' '-shared-libgcc' '-march=rv64gc'
'-mabi=lp64d' '-march=rv64imafdc' '-dumpdir' 'hellogo.'
 /usr/lib64/gcc/riscv64-suse-linux/11/collect2 -plugin
/usr/lib64/gcc/riscv64-suse-linux/11/liblto_plugin.so
-plugin-opt=/usr/lib64/gcc/riscv64-suse-linux/11/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccu6Qjw9.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id
--eh-frame-hdr -melf64lriscv -dynamic-linker /lib/ld-linux-riscv64-lp64d.so.1
-o hellogo /lib64/lp64d/crt1.o /usr/lib64/gcc/riscv64-suse-linux/11/crti.o
/usr/lib64/gcc/riscv64-suse-linux/11/crtbegin.o
-L/usr/lib64/gcc/riscv64-suse-linux/11
-L/usr/lib64/gcc/riscv64-suse-linux/11/../../../../riscv64-suse-linux/lib
-L/lib64/lp64d -L/usr/lib64/lp64d /tmp/cc1upFah.o -lgobegin -lgo -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/riscv64-suse-linux/11/crtend.o
/usr/lib64/gcc/riscv64-suse-linux/11/crtn.o
COLLECT_GCC_OPTIONS='-g1' '-o' 'hellogo' '-v' '-shared-libgcc' '-march=rv64gc'
'-mabi=lp64d' '-march=rv64imafdc' '-dumpdir' 'hellogo.'

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (3 preceding siblings ...)
  2022-01-02 12:15 ` schwab@linux-m68k.org
@ 2022-01-02 12:52 ` pinskia at gcc dot gnu.org
  2022-01-02 12:54 ` bau2wux4sh at pkv73 dot anonbox.net
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-02 12:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-02
             Status|UNCONFIRMED                 |WAITING
             Target|                            |riscv64-alpine-linux-musl
     Ever confirmed|0                           |1

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I should note that libgo is not able to compile for musl on the FSF GCC until
just recently, after r12-5979.

Also since this is alpine, this is with some patches, I don't know if those
patches change RISCV usage though.

Is there a way you can test GCC 12?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (4 preceding siblings ...)
  2022-01-02 12:52 ` pinskia at gcc dot gnu.org
@ 2022-01-02 12:54 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 13:00 ` bau2wux4sh at pkv73 dot anonbox.net
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 12:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #6 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
(In reply to Andreas Schwab from comment #4)
> LIBRARY_PATH=/usr/lib64/gcc/riscv64-suse-linux/11/:/usr/lib64/gcc/riscv64-
> suse-linux/11/../../../../riscv64-suse-linux/lib/:/lib64/lp64d/:/usr/lib64/
> lp64d/:/lib/:/usr/lib/

Hm, Alpine doesn't have /usr/lib64 and /lib64. Alpine only uses /lib and
/usr/lib. However, it seems that gcc/config/riscv/t-linux assumes that the
lib64/lib32 directory is present:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/riscv/t-linux;h=216d2776a183d13ade76642b73b9bf04b0c4694e;hb=HEAD
this is contrary to configuration files for other architectures which
explicitly check if the system has lib32/lib64, for example, compare this to
the configuration file for x86_64:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/t-linux64;h=d288b0935220cc44998da1994a13aa2902db9509;hb=HEAD#l19

Might this be the root cause of this issue?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (5 preceding siblings ...)
  2022-01-02 12:54 ` bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 13:00 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 13:01 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 13:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #7 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
(In reply to Andrew Pinski from comment #5)
> I should note that libgo is not able to compile for musl on the FSF GCC
> until just recently, after r12-5979.

This patch is included with the Alpine version of GCC, see
https://git.alpinelinux.org/aports/tree/main/gcc/0040-stddef.h-add-support-for-musl-typedef-macro-guards.patch
there are also additional patches which need to be merged upstream before one
can use gcc-go on musl (see the Alpine Git for the complete list).  As I said:
Alpine is currently working on upstreaming these patches. For example,
https://gcc.gnu.org/pipermail/gcc-patches/2021-December/587142.html

The problem described in this bug report should not be specific to any of those
gccgo/libgo patches, it rather seems to be a problem with the default
LIBRARY_PATH (see my previous comment).

> Is there a way you can test GCC 12?

I need to rebase the Alpine patchset for that GCC 12 then I assume, I could
that do that if all else fails.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (6 preceding siblings ...)
  2022-01-02 13:00 ` bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 13:01 ` pinskia at gcc dot gnu.org
  2022-01-02 13:20 ` bau2wux4sh at pkv73 dot anonbox.net
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-02 13:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also there is much support we can do on modified sources really. But I didn't
see any patches which would have modified this part. I suspect there is some
funny multilib/non-multilib going on with RISCV port really. It might make
sense to actually have some real non-multilib MUSL support so you don't need to
do --disable-multilib which I think is recorded in general in PR 90077.
Each musl target should have its own t-* file which unsets the MULTI* make
variables.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (7 preceding siblings ...)
  2022-01-02 13:01 ` pinskia at gcc dot gnu.org
@ 2022-01-02 13:20 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 13:25 ` [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 13:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #9 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
(In reply to Andrew Pinski from comment #8)
> Also there is much support we can do on modified sources really.

Yes, I totally understand that I was just looking for some guidance on how to
debug this further to come up with a fix.

> But I didn't see any patches which would have modified this part.

Right. I also don't think this is a problem introduced by the Alpine patchset.

> I suspect there is some funny multilib/non-multilib going on with RISCV port really.

So the problem isn't that gcc/config/riscv/t-linux assumes lib32/lib64
directories to be present? I just find this surprising because other
architecture configuration files I looked at include a specific check to ensure
that these directories are present.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (8 preceding siblings ...)
  2022-01-02 13:20 ` bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 13:25 ` pinskia at gcc dot gnu.org
  2022-01-02 14:01 ` [Bug target/103889] " bau2wux4sh at pkv73 dot anonbox.net
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-02 13:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|gccgo is unable to find its |gccgo is unable to find its
                   |standard library by default |standard library by default
                   |on 64-Bit RISC-V            |on 64-Bit RISC-V due to
                   |                            |musl not using multilib but
                   |                            |still uses t-linux
             Status|WAITING                     |NEW

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well RISCV port is new enough that nobody has tested --disable-multilib and put
things in /lib/ really. Really there should be a gcc/config/riscv/t-linux-musl
which does no do any of the multilib stuff and that should be used for musl
only.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug target/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (9 preceding siblings ...)
  2022-01-02 13:25 ` [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux pinskia at gcc dot gnu.org
@ 2022-01-02 14:01 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-02 14:05 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 14:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #11 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
(In reply to Andrew Pinski from comment #10)
> Well RISCV port is new enough that nobody has tested --disable-multilib and
> put things in /lib/ really. Really there should be a
> gcc/config/riscv/t-linux-musl which does no do any of the multilib stuff and
> that should be used for musl only.

Right, but I assume this problem should also exist on glibc systems which only
have /lib/ instead of /lib64/ then. So apart from adding a
gcc/config/riscv/t-linux-musl file in the future, the existing
gcc/config/riscv/t-linux should also be fixed IMHO :)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug target/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (10 preceding siblings ...)
  2022-01-02 14:01 ` [Bug target/103889] " bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-02 14:05 ` pinskia at gcc dot gnu.org
  2022-01-02 15:31 ` bau2wux4sh at pkv73 dot anonbox.net
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-02 14:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to John Doe from comment #11)
> Right, but I assume this problem should also exist on glibc systems which
> only have /lib/ instead of /lib64/ then. So apart from adding a
> gcc/config/riscv/t-linux-musl file in the future, the existing
> gcc/config/riscv/t-linux should also be fixed IMHO :)

Because the Linux-gnu folks will always use lib64 instead of lib here. So there
is no need to fix gcc/config/riscv/t-linux. There is a LSF on purpose which I
thought defined this all for *-*-linux-gnu across distros.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug target/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (11 preceding siblings ...)
  2022-01-02 14:05 ` pinskia at gcc dot gnu.org
@ 2022-01-02 15:31 ` bau2wux4sh at pkv73 dot anonbox.net
  2022-01-03 21:32 ` wilson at gcc dot gnu.org
  2022-01-07 10:06 ` bau2wux4sh at pkv73 dot anonbox.net
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-02 15:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

--- Comment #13 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
(In reply to Andrew Pinski from comment #12)
> Because the Linux-gnu folks will always use lib64 instead of lib here. So
> there is no need to fix gcc/config/riscv/t-linux. There is a LSF on purpose
> which I thought defined this all for *-*-linux-gnu across distros.

What is LSF? Do you mean LSB (Linux Standard Base)? Because the comment in the 
t-linux64 i386 configuration file explicitly states:

> The LSB does not enforce the use of /lib64 and /usr/lib64

I might be repeating myself but other architecture configuration files
explicitly include a check to ensure that this directory exists, e.g.:

> $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)

Then again I am personally not very familiar with these configuration files, it
just seems odd to me that the RISC-V one doesn't have such a check.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug target/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (12 preceding siblings ...)
  2022-01-02 15:31 ` bau2wux4sh at pkv73 dot anonbox.net
@ 2022-01-03 21:32 ` wilson at gcc dot gnu.org
  2022-01-07 10:06 ` bau2wux4sh at pkv73 dot anonbox.net
  14 siblings, 0 replies; 16+ messages in thread
From: wilson at gcc dot gnu.org @ 2022-01-03 21:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wilson at gcc dot gnu.org

--- Comment #14 from Jim Wilson <wilson at gcc dot gnu.org> ---
The RISC-V ABI defines 6 different ABIs currently (not including rv32e
support), so the old /lib and /lib64 distinction isn't enough.  We define 6
different directories where the libraries can be, depending on the ABI in use. 
For rv64/lp64d, the most common one, they go in /lib64/lp64d.  Desktop linux
does not use all of these ABIs, but embedded linux does.

Alibaba/T-Head incidentally has written linux kernel and qemu support for
running 32-bit code on a rv64 kernel, but I don't know if they have hardware
that supports this yet, and don't know if they are multilibbing/multiarching
yet.  I think it is only a matter of time before we have to support both 32-bit
and 64-bit code on rv64 systems.

Anyways, the first thing I would try is to make some links.  You can make
/lib64 a link to /lib, and make a /lib/lp64d link that points back at lib. 
Hence /lib64/lp64d will point at /lib.  Likewise for /usr/lib64/lp64d to point
at /usr/lib.  Then see if gccgo works.  Some linux distros already have these
links.  Adding these links to the OS might be the simplest solution if it
works.

If you don't link the symlink idea, then we probably need a new t-linux-musl
file.  And if you are using GNU Binutils, then you need GNU ld changes, since
it is hardwired to use the same dirs.  And if you are using glibc then you need
glibc changes too, but you mentioned musl so this doesn't apply to you, but
would apply to others if they want the same kind of changes for another linux
distro.

On a Fedora RISC-V system
[wilson@fedora-riscv /]$ ls -lt lib64
lrwxrwxrwx. 1 root root 9 Aug 12  2020 lib64 -> usr/lib64
[wilson@fedora-riscv /]$ cd /usr/lib64
[wilson@fedora-riscv lib64]$ ls -lt lp64d
lrwxrwxrwx. 1 root root 1 Aug  4 07:18 lp64d -> .
[wilson@fedora-riscv lib64]$ 
So both /lib64/lp64d and /usr/lib64/lp64d work, and point to the same place.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug target/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux
  2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
                   ` (13 preceding siblings ...)
  2022-01-03 21:32 ` wilson at gcc dot gnu.org
@ 2022-01-07 10:06 ` bau2wux4sh at pkv73 dot anonbox.net
  14 siblings, 0 replies; 16+ messages in thread
From: bau2wux4sh at pkv73 dot anonbox.net @ 2022-01-07 10:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889

John Doe <bau2wux4sh at pkv73 dot anonbox.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #15 from John Doe <bau2wux4sh at pkv73 dot anonbox.net> ---
Alpine now includes a patch which forces use of ../lib by modifying both the
gcc/config/riscv/t-linux as well as gcc/config/riscv/linux.h (to change the
startfile_prefix_spec to not use lib64/lib32):

   
https://git.alpinelinux.org/aports/diff/main/gcc/0029-riscv-disable-multilib-support.patch?id=0c4c5e44502735414688a35200af9b14f3f5f4a2

I can confirm that this patch also fixes gccgo on musl targets. Therefore, this
is not gccgo-specific issue but rather a duplicate of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077

*** This bug has been marked as a duplicate of bug 90077 ***

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-01-07 10:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-02 11:20 [Bug go/103889] New: gccgo is unable to find its standard library by default on 64-Bit RISC-V bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 11:22 ` [Bug go/103889] " bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 11:45 ` schwab@linux-m68k.org
2022-01-02 11:48 ` bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 12:15 ` schwab@linux-m68k.org
2022-01-02 12:52 ` pinskia at gcc dot gnu.org
2022-01-02 12:54 ` bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 13:00 ` bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 13:01 ` pinskia at gcc dot gnu.org
2022-01-02 13:20 ` bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 13:25 ` [Bug go/103889] gccgo is unable to find its standard library by default on 64-Bit RISC-V due to musl not using multilib but still uses t-linux pinskia at gcc dot gnu.org
2022-01-02 14:01 ` [Bug target/103889] " bau2wux4sh at pkv73 dot anonbox.net
2022-01-02 14:05 ` pinskia at gcc dot gnu.org
2022-01-02 15:31 ` bau2wux4sh at pkv73 dot anonbox.net
2022-01-03 21:32 ` wilson at gcc dot gnu.org
2022-01-07 10:06 ` bau2wux4sh at pkv73 dot anonbox.net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).