Seeking advice on building riscv-unknown-linux-gnu

1,040 views
Skip to first unread message

UA

unread,
Jun 18, 2016, 5:18:14 PM6/18/16
to RISC-V SW Dev
Hi riscv enthusiasts,

I am trying to build the riscv gcc toolchain for linux. I have spent 3 days now on different commit points (like the rocket-chip master commit, riscv-tools master commit and the riscv-gnu-toolchain master tags). I managed to get the toolchain working once by luck but I am not able to reproduce it. Amidst all my mess, I also managed to lose the working version and am not able to do anything to get riscv-unknown-linux-gnu-gcc to work.

I am first using build.sh to build the entire newlib toolchain. riscv-unknown-elf-gcc works ok for me. After that I add bin of the previous installation to my path and then try to 'make linux' in the build area as per the README. However, my build exits without an error but I noticed that stage 2 of my glibc build hasnt even started. My stamps directory looks like this:
build-binutils-linux  build-gcc-linux-stage1  build-glibc-linux-headers  build-linux-headers

Am I to set CC and CXX to something in between? Is there any suggested commit tag where 'make linux' just works? I believe a lot of people on this group might have been through this situation too. I value all your suggestions to help me get passed this.

Thanks a ton,
UA

John Leidel

unread,
Jun 18, 2016, 6:37:25 PM6/18/16
to UA, RISC-V SW Dev
UA, what platform are you building on?

-- John D. Leidel 
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/45a191f9-fe6f-4d22-80d2-f91f450dfc21%40groups.riscv.org.

Uber An

unread,
Jun 18, 2016, 6:42:33 PM6/18/16
to John Leidel, RISC-V SW Dev
Hi John,

I am using CentOS 6.7 (with devtoolset-2). And thanks for offering to help :)

Regards

Palmer Dabbelt

unread,
Jun 18, 2016, 8:33:59 PM6/18/16
to uberm...@gmail.com, john....@gmail.com, sw-...@groups.riscv.org
That's exactly the same platform I build on, so it should be possible to make
this work.

"make linux" should work on every commit of riscv-gnu-toolchain. Are you sure
you're correct about the build terminating without an error? It can be really
tricky to see build errors in parallel makes. What happens if you run

make linux; echo "make exited with $?"

? That will print the make error code right after make exits. If make doesn't
return 0 then there was an error that's just hidden in the scrollback, you can
frequently find it more easily with a "make -j1".

On Sat, 18 Jun 2016 15:42:31 PDT (-0700), uberm...@gmail.com wrote:
> Hi John,
>
> I am using CentOS 6.7 (with devtoolset-2). And thanks for offering to help
> :)
>
> Regards
>
> On Sat, Jun 18, 2016 at 3:37 PM, John Leidel <john....@gmail.com> wrote:
>
>> UA, what platform are you building on?
>>
>> -- John D. Leidel
>>
>> On Jun 18, 2016, at 4:18 PM, UA <uberm...@gmail.com> wrote:
>>
>> Hi riscv enthusiasts,
>>
>> I am trying to build the riscv gcc toolchain for linux. I have spent 3
>> days now on different commit points (like the rocket-chip master commit,
>> riscv-tools master commit and the riscv-gnu-toolchain master tags). I
>> managed to get the toolchain working once by luck but I am not able to
>> reproduce it. Amidst all my mess, I also managed to lose the working
>> version and am not able to do anything to get riscv-unknown-linux-gnu-gcc
>> to work.
>>
>> I am first using build.sh to build the entire newlib toolchain.
>> riscv-unknown-elf-gcc works ok for me. After that I add bin of the previous
>> installation to my path and then try to 'make linux' in the build area as
>> per the README. However, my build exits without an error but I noticed that *stage
>> 2 of my glibc build hasnt even started*. My stamps directory looks like
>> this:
>> build-binutils-linux build-gcc-linux-stage1 build-glibc-linux-headers
>> build-linux-headers
>>
>> Am I to set CC and CXX to something in between? Is there any suggested
>> commit tag where 'make linux' just works? I believe a lot of people on this
>> group might have been through this situation too. I value all your
>> suggestions to help me get passed this.
>>
>> Thanks a ton,
>> UA
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "RISC-V SW Dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sw-dev+un...@groups.riscv.org.
>> To post to this group, send email to sw-...@groups.riscv.org.
>> Visit this group at
>> https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
>> To view this discussion on the web visit
>> https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/45a191f9-fe6f-4d22-80d2-f91f450dfc21%40groups.riscv.org
>> <https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/45a191f9-fe6f-4d22-80d2-f91f450dfc21%40groups.riscv.org?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "RISC-V SW Dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sw-dev+un...@groups.riscv.org.
>> To post to this group, send email to sw-...@groups.riscv.org.
>> Visit this group at
>> https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
>> To view this discussion on the web visit
>> https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/50FF2A5F-E84D-48F6-A300-5FB26695E988%40gmail.com
>> <https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/50FF2A5F-E84D-48F6-A300-5FB26695E988%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>>

Uber An

unread,
Jun 18, 2016, 9:17:29 PM6/18/16
to Palmer Dabbelt, John Leidel, RISC-V SW Dev
Hi Palmer,

Thanks for your suggestions. Indeed the errors were hidden in the parallel builds. Lines of error from the build log are as follows

make  subdir=iconv -C iconv ..=../ install-headers
In file included from ../sysdeps/riscv/nptl/tls.h:31:0,
                 from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:22,
                 from <stdin>:1:
../sysdeps/generic/stdint.h:148:0: error: "__INT64_C" redefined [-Werror]
 #  define __INT64_C(c) c ## LL
 ^
<stdin>:1:0: note: this is the location of the previous definition
In file included from ../sysdeps/riscv/nptl/tls.h:31:0,
                 from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:22,
                 from <stdin>:1:
../sysdeps/generic/stdint.h:149:0: error: "__UINT64_C" redefined [-Werror]
 #  define __UINT64_C(c) c ## ULL
 ^
<stdin>:1:0: note: this is the location of the previous definition
In file included from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:22:0,
                 from <stdin>:1:
../sysdeps/riscv/nptl/tls.h:44:16: error: invalid register name for ‘__thread_self’
 register void* __thread_self asm("tp");
                ^
It says cc1: all warnings are treated as errors and exits.


Are you familiar with this error by any chance?

Thanks for helping me out!
Regards

Andrew Waterman

unread,
Jun 18, 2016, 9:58:33 PM6/18/16
to Uber An, Palmer Dabbelt, John Leidel, RISC-V SW Dev
This suggests that your host compiler, rather than the RISC-V
compiler, is being used to compile this source. That might happen if
the RISC-V compiler wasn't in your PATH at some point in the build
process.
> https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAMacYFtpU9%2BA8MzVnWkw1Vu9RFtaVq%2B_%3DOtL4V%2BRrC%3DuNu51_g%40mail.gmail.com.

Uber An

unread,
Jun 18, 2016, 11:11:04 PM6/18/16
to Andrew Waterman, Palmer Dabbelt, John Leidel, RISC-V SW Dev
Hi Andrew,

First of all, thanks a lot for your inputs.

I checked the config.log of "build-glibc-linux64" folder which is the specific build during which it fails. The initial part of the log shows that I have included my riscv-installation directory (bolded below) but yet the check cannot find the riscv-unknown-linux-gnu-gcc and decides to go with the host one.

build/build-glibc-linux64/config.log is as follows:

  $ /homes/ua/riscv/rocket-chip/riscv-tools/riscv-gnu-toolchain/build-linux/src/glibc/configure --host=riscv64-unknown-linux-gnu --prefix=/usr libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes --enable-shar

## --------- ##
## Platform. ##
## --------- ##

hostname = bb-91.b.b
uname -m = x86_64
uname -r = 2.6.32-504.12.2.el6.x86_64
uname -s = Linux
uname -v = #1 SMP Wed Mar 11 22:03:14 UTC 2015

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /awk
PATH: /homes/ua/riscv/riscv-install/bin
PATH: /opt/rh/devtoolset-2/root/usr/bin
PATH: /usr/lib64/qt-3.3/bin
PATH: /usr/local/bin
PATH: /bin
PATH: /usr/bin
PATH: /usr/local/sbin
PATH: /usr/sbin
PATH: /sbin
PATH: /homes/ua/riscv/riscv-install/bin
PATH: /gro/cad/synopsys/vcs/J-2014.12-SP2/bin

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2416: checking build system type
configure:2430: result: x86_64-unknown-linux-gnu
configure:2450: checking host system type
configure:2463: result: riscv64-unknown-linux-gnu
configure:2492: checking for riscv64-unknown-linux-gnu-gcc
configure:2519: result: /opt/rh/devtoolset-2/root/usr/bin/gcc
configure:2788: checking for C compiler version
configure:2797: /opt/rh/devtoolset-2/root/usr/bin/gcc --version >&5



Yes indeed as you suspected, there is some issue with the required riscv-gcc being made available somewhere internally in the 'make linux' flow, inspite of me including the path before running the command. But unfortunately, I dont have any handle on what goes between intermediate builds of 'make linux'. All I really do in my makefile is:

RISCV=/homes/ua/riscv/riscv-install
export PATH:=/opt/rh/devtoolset-2/root/usr/bin:$(PATH):$(RISCV)/bin

build-linux:
  mkdir rocket-chip/riscv-tools/riscv-gnu-toolchain/build-linux
  cd rocket-chip/riscv-tools/riscv-gnu-toolchain/build-linux; ../configure --prefix=$(RISCV); make -j1 linux


Does the 'make linux' flow not enforce the appropriate riscv gcc path to be used, internally? Is there a way for me to modify the makefile to this effect?

Thanks in advance!

Regards

Palmer Dabbelt

unread,
Jun 18, 2016, 11:15:52 PM6/18/16
to uberm...@gmail.com, Andrew Waterman, john....@gmail.com, sw-...@groups.riscv.org
It sounds like something is either wrong with the Makefile or wrong with PATH.
Can you try:

* Making a new build directory in riscv-gnu-toolchain, running
mkdir build-linux
cd build-linux
../configure --enable-linux --prefix=$RISC
make
* Using my script, which makes an install directory and sets RISCV and PATH
correctly:
curl https://raw.githubusercontent.com/palmer-dabbelt/home/master/.local/src/local-scripts/mkenter.bash > mkenter.bash
chmod +x mkenter.bash
./mkenter.bash

If the first one fixes the problem, it's a Makefile problem. If the second one
fixes the problem, then something is wrong with PATH getting set.
> *PATH: /homes/ua/riscv/riscv-install/bin*
> PATH: /opt/rh/devtoolset-2/root/usr/bin
> PATH: /usr/lib64/qt-3.3/bin
> PATH: /usr/local/bin
> PATH: /bin
> PATH: /usr/bin
> PATH: /usr/local/sbin
> PATH: /usr/sbin
> PATH: /sbin
> PATH: /homes/ua/riscv/riscv-install/bin
> PATH: /gro/cad/synopsys/vcs/J-2014.12-SP2/bin
>
> ## ----------- ##
> ## Core tests. ##
> ## ----------- ##
>
> configure:2416: checking build system type
> configure:2430: result: x86_64-unknown-linux-gnu
> configure:2450: checking host system type
> configure:2463: result: riscv64-unknown-linux-gnu
>
>
> *configure:2492: checking for riscv64-unknown-linux-gnu-gccconfigure:2519:
> result: /opt/rh/devtoolset-2/root/usr/bin/gcc*configure:2788: checking for
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAMacYFthkdJC5yMShFSnDs5rOXY-%3D%3DLYDA5kt3zFq5qn%2BX%3DRZA%40mail.gmail.com.

Uber An

unread,
Jun 19, 2016, 2:37:47 PM6/19/16
to Palmer Dabbelt, Andrew Waterman, John Leidel, RISC-V SW Dev
Hi Palmer & Andrew,

Sorry for the delayed response. I tried several combinations of what you suggested that is with setting the PATH through your script and with/without a makefile but all in vain. Also, each time I created a new build directory and configured from scratch.

I used a modified build.sh (modification bolded) script from the repo to make sure I am not missing something.

. build.common

echo "Starting RISC-V Toolchain build process"

build_project riscv-fesvr --prefix=$RISCV
build_project riscv-isa-sim --prefix=$RISCV --with-fesvr=$RISCV
build_project riscv-gnu-toolchain --enable-linux --prefix=$RISCV

echo -e "\\nRISC-V Toolchain installation completed!"


My PATH variable (before the build script is launched) contains the installation area with highest precedence as shown below. Is the order of riscv-install and devtoolset-2 in PATH acceptable (from the perspective of the makefile for linux)?

>echo $PATH
>/homes/ua/riscv/riscv-install/bin:/opt/rh/devtoolset-2/root/usr/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin

>which gcc
>/opt/rh/devtoolset-2/root/usr/bin/gcc

>which riscv64-unknown-linux-gnu-gcc
>/homes/ua/riscv/riscv-install/bin/riscv64-unknown-linux-gnu-gcc


However, I continue to get the error same error during riscv-gnu-toolchain make. The riscv64-unknown-linux-gnu-gcc is available but the riscv-glibc-linux64 configure still doesn't find it. Can you please suggest to me how I can enforce the 'riscv-glibc-linux64 configure' to find the riscv64-unknown-linux-gnu-gcc?

Regards,
UA

Uber An

unread,
Jun 19, 2016, 10:04:11 PM6/19/16
to Palmer Dabbelt, Andrew Waterman, John Leidel, RISC-V SW Dev
Hi Palmer,

If I may ask, may I take a look at your "config.log" for a successful build of riscv tools for linux. There is some issue with hidden variables which is not very evident and I would like to compare against a working version. I am grateful to you for your assistance. If you have any other suggestions please let me know.

Thanks!

Regards
UA

jamey.hicks

unread,
Jun 28, 2016, 12:03:51 PM6/28/16
to RISC-V SW Dev

I'm running into the same problem. Did a Google search, and there was the same failure in a riscv/riscv-tools travis build from the travis-dev branch:

The next commit on the travis-dev branch built successfully. That commit updated the riscv-gnu-toolchain to 728afcddcb0526a0f6560c4032da82805f054d58, which is where we are now.

I'm not seeing this error when building on my own Trusty and Xenial machines, only on Travis.

John Leidel

unread,
Jun 28, 2016, 12:09:52 PM6/28/16
to jamey.hicks, RISC-V SW Dev
Careful moving past the known releases with the submodules. If you get too far out of sync, the simulator may not behave as expected. 

-- John D. Leidel 
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.

Jamey Hicks

unread,
Jun 28, 2016, 12:19:25 PM6/28/16
to John Leidel, RISC-V SW Dev
How do you define release? I define release as a tagged commit. There do not appear to be any releases in github for riscv-tools or riscv-gnu-toolchain.

As far as I can tell, I'm using the versions of the submodules that match the top level commit. I would be much more confident if there were some tags in the repos.

Jamey Hicks

unread,
Jun 28, 2016, 1:16:04 PM6/28/16
to John Leidel, RISC-V SW Dev
I thought I had a successful travis build, but it seems it just masked the error and so it did not complete the build of glibc.


Reply all
Reply to author
Forward
0 new messages