LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 05-18-2018, 09:57 PM   #1
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Rep: Reputation: Disabled
Building rustc-1.25.0 from BLFS SVN


I use the SVN versions of both LFS and BLFS, so everything is pretty much on the bleeding edge. Because Firefox has required rustc for the past several releases, I keep rustc up to date.

Here's the problem: Using the supplied config.toml file per the instructions results in a failure when it comes time to build rustc_llvm, in particular the PassWrapper.cpp file. The error message is lengthy so I'll condense it down to just the salient portion:

Code:
cargo:warning=c++: error: unrecognized command line option '-Wcovered-switch-default'; did you mean '-Wno-switch-default'?
cargo:warning=c++: error: unrecognized command line option '-Wstring-conversion'; did you mean '-Wint-conversion'?
cargo:warning=c++: error: unrecognized command line option '-fcolor-diagnostics'
exit code 1
[...]
"../rustllvm/PassWrapper.cpp" with args "c++" did not execute successfully
Further research reveals that these compiler flags are applicable to clang++ and NOT GNU's c++. Evidently the mere presence of the LLVM-6.0 toolchain is sufficient to trigger the passing of these flags to the compiler, even if it's NOT clang++. There's some cmake trickery used to select these flags but it evidently doesn't account for GNU's compiler.

I've solved the problem by altering the BLFS build script by adding these commands just prior to invoking x.py:

Code:
export CC=clang
export CXX=clang++
In short, rather than trying to fight the battle of those LLVM-style flags being passed to the compiler, I've surrendered by just using the LLVM toolchain for the build.

All works well...rustc-1.25.0 builds and installs cleanly and as a result, the current Firefox-60.0 also builds and runs without error.

Since the LFS/BLFS authors are careful to test everything, I'm left wondering how rustc-1.25.0 gets built without making the change I cited?
 
Old 05-19-2018, 03:20 PM   #2
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by re_nelson View Post
Since the LFS/BLFS authors are careful to test everything, I'm left wondering how rustc-1.25.0 gets built without making the change I cited?
As a followup to my post, I've identified the source of the problem involving options passed to GNU's c++ that are only recognized by the LLVM toolchain. The ./src/librustc_llvm/build.rs file contains a call to llvm-config to request --cxxflags. With LLVM-6.0, those compiler flags include these options not recognized by the default system GNU compiler:

Code:
-Werror=unguarded-availability-new
-Wcovered-switch-default
-Wstring-conversion
-fcolor-diagnostics
Hacking that build.rs file to skip those options permits a successful build without using clang++.

Still the question remains, how was a rustc-1.25.0 build possible without either hacking that one file or specifying CXX=clang++, neither of which are mentioned in the BLFS instructions? Has anyone has success building rustc by following the steps without the deviations I cited?
 
Old 05-20-2018, 06:36 AM   #3
plasmonics
Member
 
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224

Rep: Reputation: 69
Quote:
Originally Posted by re_nelson View Post
Has anyone has success building rustc by following the steps without the deviations I cited?
I compiled rustc without the above steps and then used it to compile firefox. I believe llvm is merely an option in the BLFS book and is not absolutely required. I have BLFS running without llvm on two machines, one with radeon and the other with nVidia pascal GPU. AFAIK, llvm is only needed to build certain gallium drivers. See this thread.

Last edited by plasmonics; 05-20-2018 at 11:29 AM.
 
Old 05-21-2018, 01:27 AM   #4
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo~amd64, CentOS-7, Slackware64-current, FreeBSD-11.1, Arch
Posts: 229

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by plasmonics View Post
I compiled rustc without the above steps and then used it to compile firefox. I believe llvm is merely an option in the BLFS book and is not absolutely required. [...] AFAIK, llvm is only needed to build certain gallium drivers.
I've been tracking LLVM ever since it was first introduced not because of needing video drivers but for, IMHO, the superior diagnostics clang++ has over GNU's c++. (Although recent versions of the GNU toolchain have been getting much better in this regard).

To the point of the thread, subsequent tests have confirmed that as long as LLVM-6.0.0 is installed, then it is necessary to prefix the x.py build script with CXX=clang++. The --cxxflags provided by llvm-config are not compatible with GNU's c++. Since the remedy is so simple, I'll just go ahead and mark this thread as SOLVED.
 
Old 05-31-2018, 12:58 AM   #5
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
All my build scripts point to clang and clang++ for compiling unless it absolutely requires gcc and g++. No problems yet other than a problem with JFS as of recent with shutdowns, but otherwise, its been all good.
 
Old 06-25-2018, 09:29 PM   #6
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Rep: Reputation: 167Reputation: 167
I don't bother building rustc from scratch because you really can't build it from scratch. There is no building rust without downloading a precompiled binary that acts as a bootstrap compiler. If you tried to build a rust package for a completely new processor you'd be SOL unless you wrote your own cross plugin for rustc first. IIRC The actual original rust compiler was written in LISP or some such and is no longer a viable option from what I understand. (No, I don't know why they call it rust(c) either, that whole project seems a bit scatter-brained in its implementation.) That being the case, I just use the curl based installer command on my lfsdev account, which is the one I use for building and installing packages.
 
  


Reply

Tags
c++, clang, cmake, llvm, rustc



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BLFS-SVN: glib-2.46.0 re_nelson Linux From Scratch 2 10-14-2015 12:57 PM
[SOLVED] LFS/BLFS SVN: gcc-4.8.0 and glibc-2.17 re_nelson Linux From Scratch 3 07-09-2013 10:50 PM
[SOLVED] BLFS svn Firefox build error AndrewJM Linux From Scratch 5 06-17-2011 01:53 PM
[SOLVED] BLFS svn Dbus won't start AndrewJM Linux From Scratch 1 06-14-2011 04:46 PM
BLFS-svn package dwnload zkillz Linux From Scratch 3 10-04-2006 10:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 02:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration