Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gcc to 10.1 and turn C++ support on #31

Merged
merged 8 commits into from
Sep 24, 2021
Merged

Conversation

PiotrZierhoffer
Copy link
Contributor

These changes update gcc to 10.1 and add C++ support for gcc with newlib.

This addresses #25.

Simply adding c++ to --enable-lanaguages does not work, as libstdc++-v3 compilation fails (example in run#3559265510).

Relevant error
2021-09-09T17:50:07.1357393Z checking for EOWNERDEAD... no
2021-09-09T17:50:07.4128896Z configure: WARNING: uchar.h: present but cannot be compiled
2021-09-09T17:50:07.4131294Z configure: WARNING: uchar.h:     check for missing prerequisite headers?
2021-09-09T17:50:07.4132244Z configure: WARNING: uchar.h: see the Autoconf documentation
2021-09-09T17:50:07.4133308Z configure: WARNING: uchar.h:     section "Present But Cannot Be Compiled"
2021-09-09T17:50:07.4135065Z configure: WARNING: uchar.h: proceeding with the compiler's result
2021-09-09T17:50:07.4752788Z configure: WARNING: sys/ioctl.h: present but cannot be compiled
2021-09-09T17:50:07.4753965Z configure: WARNING: sys/ioctl.h:     check for missing prerequisite headers?
2021-09-09T17:50:07.4754907Z configure: WARNING: sys/ioctl.h: see the Autoconf documentation
2021-09-09T17:50:07.4755833Z configure: WARNING: sys/ioctl.h:     section "Present But Cannot Be Compiled"
2021-09-09T17:50:07.4757419Z configure: WARNING: sys/ioctl.h: proceeding with the compiler's result
2021-09-09T17:50:07.5768378Z configure: WARNING: sys/uio.h: present but cannot be compiled
2021-09-09T17:50:07.5769546Z configure: WARNING: sys/uio.h:     check for missing prerequisite headers?
2021-09-09T17:50:07.5770469Z configure: WARNING: sys/uio.h: see the Autoconf documentation
2021-09-09T17:50:07.5771395Z configure: WARNING: sys/uio.h:     section "Present But Cannot Be Compiled"
2021-09-09T17:50:07.5772939Z configure: WARNING: sys/uio.h: proceeding with the compiler's result
2021-09-09T17:50:07.6197657Z configure: WARNING: fenv.h: present but cannot be compiled
2021-09-09T17:50:07.6198800Z configure: WARNING: fenv.h:     check for missing prerequisite headers?
2021-09-09T17:50:07.6199751Z configure: WARNING: fenv.h: see the Autoconf documentation
2021-09-09T17:50:07.6200656Z configure: WARNING: fenv.h:     section "Present But Cannot Be Compiled"
2021-09-09T17:50:07.6202142Z configure: WARNING: fenv.h: proceeding with the compiler's result
2021-09-09T17:50:07.6947584Z configure: WARNING: stdbool.h: present but cannot be compiled
2021-09-09T17:50:07.6948809Z configure: WARNING: stdbool.h:     check for missing prerequisite headers?
2021-09-09T17:50:07.6949778Z configure: WARNING: stdbool.h: see the Autoconf documentation
2021-09-09T17:50:07.6950705Z configure: WARNING: stdbool.h:     section "Present But Cannot Be Compiled"
2021-09-09T17:50:07.6952214Z configure: WARNING: stdbool.h: proceeding with the compiler's result
2021-09-09T17:50:07.7243875Z configure: WARNING: stdalign.h: present but cannot be compiled
2021-09-09T17:50:07.7244944Z configure: WARNING: stdalign.h:     check for missing prerequisite headers?
2021-09-09T17:50:07.7245921Z configure: WARNING: stdalign.h: see the Autoconf documentation
2021-09-09T17:50:07.7246856Z configure: WARNING: stdalign.h:     section "Present But Cannot Be Compiled"
2021-09-09T17:50:07.7248348Z configure: WARNING: stdalign.h: proceeding with the compiler's result
2021-09-09T17:50:07.7541210Z configure: error: computing EOF failed
2021-09-09T17:50:07.7953876Z make[1]: *** [Makefile:11271: configure-target-libstdc++-v3] Error 1
2021-09-09T17:50:07.7960292Z make: *** [Makefile:954: all] Error 2

Updating --prefix config option helps and fixes compilation process.

Unfortunately it doesn't run properly.
$ riscv32-elf-g++ main.cpp
riscv32-elf-g++: fatal error: cannot read spec file '/home/user/conda/miniconda3/envs/gcc/lib/gcc/': Is a directory
compilation terminated.

$ riscv32-elf-gcc main.cpp
riscv32-elf-gcc: error: main.cpp: C++ compiler not installed on this system

$ riscv32-elf-newlib-g++ main.cpp
riscv32-elf-newlib-g++: fatal error: cannot read spec file '/home/user/conda/miniconda3/envs/gcc/lib/gcc/': Is a directory
compilation terminated.

$ cat main.cpp
#include <iostream>

using namespace std;

int main(){
        cout << "Hello World!" << endl;
        bool x = true;
        return x;
}

conda-build rewrites the internal paths to get rid of the build prefix, but then gcc fails to locate necessary files. We can investigate that further in the next step.

Adding build/detect_binary_files_with_prefix: False value to gcc/newlib/meta.yaml partially fixes the problem.

gcc and g++ work correctly now, but simple strings execution reveals, that paths from build process are still present in the binaries.
It doesn't seem to affect the gcc functionality though.

@PiotrZierhoffer
Copy link
Contributor Author

FYI @mithro, @tcal-x

@mithro
Copy link
Member

mithro commented Sep 22, 2021

@mithro
Copy link
Member

mithro commented Sep 22, 2021

There is some talk about how libstdc++ and stuff need to be deferred as part of cross compiling at https://www.linuxfromscratch.org/lfs/view/stable/chapter05/gcc-libstdc++-pass1.html

@mithro
Copy link
Member

mithro commented Sep 22, 2021

michalsieron and others added 2 commits September 24, 2021 12:41
gcc-10 and above flipped a default from -fcommon to -fno-common.
SH version of newlib has duplicate symbols after compiling with GCC
10.1.
@PiotrZierhoffer
Copy link
Contributor Author

For some reason the upload hangs, but all other jobs passed. Merging, I suspect a github hiccup here

@PiotrZierhoffer PiotrZierhoffer merged commit aaab650 into master Sep 24, 2021
@umarcor umarcor deleted the gcc-newlib-10.1 branch May 24, 2022 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants