Building RISC-V toolchains on FreeBSD 11.0

251 views
Skip to first unread message

Kimura Masayuki

unread,
Oct 16, 2016, 9:13:56 AM10/16/16
to sw-...@groups.riscv.org, Kimura Masayuki
Hi,

I'm trying to build FreeBSD for RISC-V on FreeBSD 11.0 platform.
I use FreeBSD 11.0 vagrant box and reference https://wiki.freebsd.org/riscv .
I checked out riscv repositories clone https://github.com/freebsd-riscv/riscv-gnu-toolchain, revision c875e2fa338f712a3138bf74fa897702c7883231
And I faced trouble of building bbl as follows.

checking build system type... x86_64-unknown-freebsd11.0
checking host system type... riscv64-unknown-freebsd11.0
checking for riscv64-unknown-freebsd11.0-gcc... riscv64-unknown-freebsd11.0-gcc
checking whether the C compiler works... no
configure: error: in `/home/vagrant/riscv-pk/build':
configure: error: C compiler cannot create executables
See `config.log' for more details

and, I checked build result of riscv-gnu-toolchain. 

For example, when I tried to cross-compile using riscv64-unknown-freebsd11.0-gcc. I think crt1 and some libraries are not compiled:
% cat main.c
int main()
{
  ;
  return 0;
}
% riscv64-unknown-freebsd11.0-gcc main.c
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find crt1.o: No such file or directory
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find crti.o: No such file or directory
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find crtbegin.o: No such file or directory
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find -lgcc
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find -lc
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find -lgcc
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find crtend.o: No such file or directory
/home/vagrant/riscv/lib/gcc/riscv64-unknown-freebsd11.0/6.1.0/../../../../riscv64-unknown-freebsd11.0/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Do you know any ways to fix them?

Thanks.
Masayuki Kimura

Ruslan Bukin

unread,
Oct 16, 2016, 1:16:41 PM10/16/16
to Kimura Masayuki, sw-...@groups.riscv.org
Hi Kimura:

Build freebsd world & kernel first, then build BBL

Ruslan

On Sun, Oct 16, 2016 at 01:13:45PM +0000, Kimura Masayuki wrote:
> Hi,
> I'm trying to build FreeBSD for RISC-V on FreeBSD 11.0 platform.
> I use FreeBSD 11.0 vagrant box and
> reference [1]https://wiki.freebsd.org/riscv .
> I checked out riscv repositories
> clone [2]https://github.com/freebsd-riscv/riscv-gnu-toolchain, revision
> --
> 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 [3]sw-dev+un...@groups.riscv.org.
> To post to this group, send email to [4]sw-...@groups.riscv.org.
> Visit this group at
> [5]https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit
> [6]https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFxSv123qrWfd42SZZx%2BuTzQMu5BQ4rSznpgCP4qK2PJcW0qRw%40mail.gmail.com.
>
> References
>
> Visible links
> 1. https://wiki.freebsd.org/riscv
> 2. https://github.com/freebsd-riscv/riscv-gnu-toolchain
> 3. mailto:sw-dev+un...@groups.riscv.org
> 4. mailto:sw-...@groups.riscv.org
> 5. https://groups.google.com/a/groups.riscv.org/group/sw-dev/
> 6. https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFxSv123qrWfd42SZZx%2BuTzQMu5BQ4rSznpgCP4qK2PJcW0qRw%40mail.gmail.com?utm_medium=email&utm_source=footer

Kimura Masayuki

unread,
Oct 17, 2016, 8:39:14 PM10/17/16
to Ruslan Bukin, sw-...@groups.riscv.org
Hi Ruslan,

Thanks. But following errors are remained.

% setenv MAKEOBJDIRPREFIX /home/vagrant/obj
% make TARGET_ARCH=riscv64 buildworld

sh /home/vagrant/freebsd-riscv/tools/install.sh -o root -g wheel -m 444  /dev/null /home/vagrant/obj/riscv.riscv64/home/vagrant/freebsd-riscv/tmp/legacy/usr/share/tmac/mm/locale
install: /home/vagrant/obj/riscv.riscv64/home/vagrant/freebsd-riscv/tmp/legacy/usr/share/tmac/mm/locale: No such file or directory
*** Error code 71

Stop.
make[5]: stopped in /home/vagrant/freebsd-riscv/gnu/usr.bin/groff/contrib/mm
*** Error code 1

Stop.
make[4]: stopped in /home/vagrant/freebsd-riscv/gnu/usr.bin/groff/contrib
*** Error code 1

Stop.
make[3]: stopped in /home/vagrant/freebsd-riscv/gnu/usr.bin/groff
*** Error code 1

Stop.
make[2]: stopped in /home/vagrant/freebsd-riscv
*** Error code 1

Stop.
make[1]: stopped in /home/vagrant/freebsd-riscv
*** Error code 1


2016年10月18日(火) 2:55 Ruslan Bukin <ruslan...@cl.cam.ac.uk>:
no.
set MAKEOBJDIRPREFIX env variable, e.g.:
setenv MAKEOBJDIRPREFIX /home/${USER}/obj/

Ruslan

On Mon, Oct 17, 2016 at 05:40:26PM +0000, Kimura Masayuki wrote:
>    Hi Ruslan,
>    Yes I already tried and I got following errors. Does it need to build as
>    administrator?
>     % make TARGET_ARCH=riscv64 buildworld
>    --------------------------------------------------------------
>    >>> World build started on Mon Oct 17 17:32:28 UTC 2016
>    --------------------------------------------------------------
>    --------------------------------------------------------------
>    >>> Rebuilding the temporary build tree
>    --------------------------------------------------------------
>    rm -rf /usr/obj/riscv.riscv64/home/vagrant/freebsd-riscv/tmp
>    mkdir -p /usr/obj/riscv.riscv64/home/vagrant/freebsd-riscv/tmp/lib
>    mkdir: /usr/obj/riscv.riscv64: Permission denied
>    *** Error code 1
>    And I changed environment such as:
>    % make TARGET_ARCH=riscv64 MAKEOBJDIRPREFIX=/tmp buildworld
>    ...
>    sh /home/vagrant/freebsd-riscv/tools/install.sh -o root -g wheel -m 444
>     /dev/null
>    /tmp/riscv.riscv64/home/vagrant/freebsd-riscv/tmp/legacy/usr/share/tmac/mm/locale
>    install:
>    /tmp/riscv.riscv64/home/vagrant/freebsd-riscv/tmp/legacy/usr/share/tmac/mm/locale:

>    No such file or directory
>    I tried on FreeBSD 11.0. Do you have any ways to resolve them?
>    Thanks.
>    Masayuki Kimura
>    2016年10月17日(月) 2:16 Ruslan Bukin <[1]ruslan...@cl.cam.ac.uk>:

>
>      Hi Kimura:
>
>      Build freebsd world & kernel first, then build BBL
>
>      Ruslan
>
>      On Sun, Oct 16, 2016 at 01:13:45PM +0000, Kimura Masayuki wrote:
>      >    Hi,
>      >    I'm trying to build FreeBSD for RISC-V on FreeBSD 11.0 platform.
>      >    I use FreeBSD 11.0 vagrant box and
>      >    reference [1][2]https://wiki.freebsd.org/riscv .

>      >    I checked out riscv repositories
>      >   
>      >    email to [3][4]sw-dev+un...@groups.riscv.org.

>      >    To post to this group, send email to
>      [4][5]sw-...@groups.riscv.org.
>      >    Visit this group at
>      >    [5][6]https://groups.google.com/a/groups.riscv.org/group/sw-dev/.

>      >    To view this discussion on the web visit
>      >   
>      [6][7]https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFxSv123qrWfd42SZZx%2BuTzQMu5BQ4rSznpgCP4qK2PJcW0qRw%40mail.gmail.com.
>      >
>      > References
>      >
>      >    Visible links
>      >    1. [8]https://wiki.freebsd.org/riscv
>      >    2. [9]https://github.com/freebsd-riscv/riscv-gnu-toolchain
>      >    3. mailto:[10]sw-dev+un...@groups.riscv.org
>      >    4. mailto:[11]sw-...@groups.riscv.org
>      >    5. [12]https://groups.google.com/a/groups.riscv.org/group/sw-dev/
>      >    6.
>      [13]https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFxSv123qrWfd42SZZx%2BuTzQMu5BQ4rSznpgCP4qK2PJcW0qRw%40mail.gmail.com?utm_medium=email&utm_source=footer
>
> References
>
>    Visible links
>    1. mailto:ruslan...@cl.cam.ac.uk
>    2. https://wiki.freebsd.org/riscv
>    3. https://github.com/freebsd-riscv/riscv-gnu-toolchain
>    4. mailto:sw-dev%2Bunsu...@groups.riscv.org
>    5. mailto:sw-...@groups.riscv.org
>    6. https://groups.google.com/a/groups.riscv.org/group/sw-dev/
>    7. https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFxSv123qrWfd42SZZx%2BuTzQMu5BQ4rSznpgCP4qK2PJcW0qRw%40mail.gmail.com
>    8. https://wiki.freebsd.org/riscv
>    9. https://github.com/freebsd-riscv/riscv-gnu-toolchain
>   10. mailto:sw-dev%2Bunsu...@groups.riscv.org
>   11. mailto:sw-...@groups.riscv.org
>   12. https://groups.google.com/a/groups.riscv.org/group/sw-dev/
>   13. https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAFxSv123qrWfd42SZZx%2BuTzQMu5BQ4rSznpgCP4qK2PJcW0qRw%40mail.gmail.com?utm_medium=email&utm_source=footer

Yukishige Shibata

unread,
Oct 18, 2016, 1:11:39 PM10/18/16
to sw-...@groups.riscv.org
Hi, Masayuki-san,

I got same error. "git bisect" found the next commit causes the problem.

-----------------------------
commit 9a6ce764983dc9f6f836892aafa00ee8a4be6b57
Author: bapt <ba...@FreeBSD.org>
Date: Sat Oct 8 18:57:11 2016 +0000

groff is not needed in the bootstrap tools if the system is built
WITHOUT_SHAREDOCS

MFC after: 2 weeks

diff --git a/Makefile.inc1 b/Makefile.inc1
index 8393e865..9c47c71 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1586,7 +1586,7 @@ _strfile= usr.bin/fortune/strfile
_gperf= gnu/usr.bin/gperf
.endif

-.if ${MK_GROFF} != "no"
+.if ${MK_SHAREDOCS} != "no" || ${MK_GROFF} != "no"
_groff= gnu/usr.bin/groff \
usr.bin/soelim
.endif

----------------------------------

Revering it, I can build userland without any error.


On 2016/10/18 9:39, Kimura Masayuki wrote:
> Hi Ruslan,
>
> *** Error code 1--

Best regards,
-----------------
Yukishige Shibata

Ruslan Bukin

unread,
Oct 18, 2016, 1:24:15 PM10/18/16
to Yukishige Shibata, sw-...@groups.riscv.org
Hi

thanks Yukishige-san -- I reported to commit author.

Kimura-san you can revert it locally for a while.

thanks

Ruslan
> --
> 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/e8365e9f-f6c2-3987-e296-e588f26579f9%40mtd.biglobe.ne.jp.

Kimura Masayuki

unread,
Oct 18, 2016, 1:39:23 PM10/18/16
to Ruslan Bukin, Yukishige Shibata, sw-...@groups.riscv.org
Hi Yukishige, Ruslan

Thank you for your support. I had tried some commit revisions shown in https://wiki.freebsd.org/riscv, such as r303660, r303908. 

I will use reverted revesion. Thank you.

Thanks.
Masayuki Kimura


2016年10月19日(水) 2:24 Ruslan Bukin <ruslan...@cl.cam.ac.uk>:

Ruslan Bukin

unread,
Oct 18, 2016, 1:41:40 PM10/18/16
to Yukishige Shibata, sw-...@groups.riscv.org
Alternatively you can just set

setenv WITHOUT_SHAREDOCS yes

thanks

Ruslan
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/20161018172351.GB59150%40bsdpad.com.

Yukishige Shibata

unread,
Oct 18, 2016, 1:51:40 PM10/18/16
to sw-...@groups.riscv.org
Hi, Ruslan-san,

Setting WITHOUT_SHAREDOCS=yes seems better to me than reverting the commit.

Anyway. I'll update my build script to set it.

Thank you for ur quick feedback.

Kimura Masayuki

unread,
Oct 19, 2016, 9:13:16 AM10/19/16
to Yukishige Shibata, sw-...@groups.riscv.org, Ruslan Bukin
Hi Ruslan, Yukishige,

I tried them, and MYOBJDIR shoud be

setenv MYOBJDIR "/home/${USER}/obj/riscv.riscv64/home/${USER}/freebsd-riscv/"
not, 
setenv MYOBJDIR "/home/${USER}/obj/riscv.riscv64/home/${USER}/dev/freebsd-riscv/"

Thanks.
Masayuki Kimura


2016年10月19日(水) 2:51 Yukishige Shibata <y-sh...@mtd.biglobe.ne.jp>:
--
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/.
Reply all
Reply to author
Forward
0 new messages