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

using the 'arc-multilib-elf32' template, and when I only select Fortran in the C compiler, the compilation fails #2103

Open
jian256384 opened this issue Feb 2, 2024 · 10 comments

Comments

@jian256384
Copy link

[INFO ]  =================================================================
[INFO ]  Installing final gcc compiler
[EXTRA]    Configuring final gcc compiler
[EXTRA]    Building final gcc compiler
[ERROR]    configure: error: in `/home/y/Desktop/test/.build/arc-multilib-elf/build/build-cc-gcc-final/arc-multilib-elf/em_mini/libbacktrace':
[ERROR]    configure: error: C compiler cannot create executables
[ERROR]    make[3]: *** [Makefile:13216: configure-target-libbacktrace] Error 1
[ERROR]    make[2]: *** [Makefile:943: all] Error 2
[ERROR]   
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing final gcc compiler'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@376]
[ERROR]  >>        called from: do_gcc_core_backend[scripts/build/cc/gcc.sh@687]
[ERROR]  >>        called from: do_cc_for_host[scripts/build/cc/gcc.sh@865]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@697]
[ERROR]  >>
[ERROR]  >>  For more info on this error, look at the file: 'build.log'
[ERROR]  >>  There is a list of known issues, some with workarounds, in:
[ERROR]  >>      https://crosstool-ng.github.io/docs/known-issues/
[ERROR]  >>
[config.log](https://github.com/crosstool-ng/crosstool-ng/files/14137500/config.log)

[ERROR]  >>  If you feel this is a bug in crosstool-NG, report it at:
[ERROR]  >>      https://github.com/crosstool-ng/crosstool-ng/issues/
[ERROR]  >>
[ERROR]  >>  Make sure your report includes all the information pertinent to this issue.
[ERROR]  >>  Read the bug reporting guidelines here:
[ERROR]  >>      http://crosstool-ng.github.io/support/
[ERROR]   
[ERROR]  (elapsed: 22:28.22)
[22:29] / gmake[1]: *** [/home/y/Desktop/ct-ng/bin/ct-ng:261: build] Error 2
gmake: *** [/home/y/Desktop/ct-ng/bin/ct-ng:265: build.48] Error 2

config.log
config.txt

Is it not possible to run Fortran on bare metal?

@QBos07
Copy link
Contributor

QBos07 commented Feb 3, 2024

As for the things I know Fortran is currently brocken on almost all configurations.

@QBos07
Copy link
Contributor

QBos07 commented Feb 3, 2024

Please upload build.log aswell.

@jian256384
Copy link
Author

jian256384 commented Feb 6, 2024

Please upload build.log aswell.

log.zip
This is the compressed package I reconstructed, which contains build.log, config.log, and config files. Could you please take a look for me?

@QBos07
Copy link
Contributor

QBos07 commented Feb 6, 2024

Oh, it's a common error on baremetal systems. configure tries to test the compiler but the linker fails because there is no crt0.o (The startfile with code thats run before main). configure tries to compile a executable to test the compiler when it's only configuring a library. There are ways around this but there are ugly, like realy ugly. For example it's possible to inject a mok-up crt0.o (compiled from some dumb code) into the savestate and/or sysroot or it shoud be possible the hardcode that check-outcome using some commando line variables.

@QBos07
Copy link
Contributor

QBos07 commented Feb 6, 2024

The quick fix here is to disable the module and everything that hard-depends on it (if even possible).

@abrodkin
Copy link
Contributor

abrodkin commented Feb 6, 2024

@jian256384 that's actually weird:

configure:3074: checking whether the C compiler works
configure:3096: .../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/build/build-cc-gcc-final-build-x86_64-build_pc-linux-gnu/./gcc/xgcc -B.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/build/build-cc-gcc-final-build-x86_64-build_pc-linux-gnu/./gcc/ -B.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/bin/ -B.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/lib/ -isystem .../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/include -isystem .../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/sys-include    -g -O2  -idirafter /home/y/x-tools/HOST-x86_64-w64-mingw32/arc-multilib-elf/arc-multilib-elf/include -g -Os  -static conftest.c  >&5
.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/bin/ld: cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
configure:3100: $? = 1
configure:3138: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "package-unused"
| #define PACKAGE_TARNAME "libbacktrace"
| #define PACKAGE_VERSION "version-unused"
| #define PACKAGE_STRING "package-unused version-unused"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3143: error: in `.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/build/build-cc-gcc-final-build-x86_64-build_pc-linux-gnu/arc-multilib-elf/libbacktrace':
configure:3145: error: C compiler cannot create executables
See `config.log' for more details

Looks like you're trying to build a canadian cross toolchain with more language front-ends enabled in the gcc (--enable-languages=c,c++,fortran,lto). But so far I don't see any obvious reason why crt0.o couldn't be found. crt0.o gets built as a part of Newlib and so I'm surprised it's not found.

Let me try to reproduce the same behavior locally and then we'll see what's wrong here.
But in the meantime it would be interesting to understand what you're trying to achieve: do you need to have a bare-metal Fortran compiler for ARC processors or it's just a random config you're experimenting with?

@QBos07
Copy link
Contributor

QBos07 commented Feb 7, 2024

Not quite right. Newlib only has a crt0.o for some configurations. For example x86_64-elf has a similar problem.

@jian256384
Copy link
Author

@jian256384 that's actually weird:

configure:3074: checking whether the C compiler works
configure:3096: .../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/build/build-cc-gcc-final-build-x86_64-build_pc-linux-gnu/./gcc/xgcc -B.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/build/build-cc-gcc-final-build-x86_64-build_pc-linux-gnu/./gcc/ -B.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/bin/ -B.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/lib/ -isystem .../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/include -isystem .../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/sys-include    -g -O2  -idirafter /home/y/x-tools/HOST-x86_64-w64-mingw32/arc-multilib-elf/arc-multilib-elf/include -g -Os  -static conftest.c  >&5
.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/buildtools/arc-multilib-elf/bin/ld: cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
configure:3100: $? = 1
configure:3138: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "package-unused"
| #define PACKAGE_TARNAME "libbacktrace"
| #define PACKAGE_VERSION "version-unused"
| #define PACKAGE_STRING "package-unused version-unused"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3143: error: in `.../arc/.build/HOST-x86_64-w64-mingw32/arc-multilib-elf/build/build-cc-gcc-final-build-x86_64-build_pc-linux-gnu/arc-multilib-elf/libbacktrace':
configure:3145: error: C compiler cannot create executables
See `config.log' for more details

Looks like you're trying to build a canadian cross toolchain with more language front-ends enabled in the gcc (--enable-languages=c,c++,fortran,lto). But so far I don't see any obvious reason why crt0.o couldn't be found. crt0.o gets built as a part of Newlib and so I'm surprised it's not found.

Let me try to reproduce the same behavior locally and then we'll see what's wrong here. But in the meantime it would be interesting to understand what you're trying to achieve: do you need to have a bare-metal Fortran compiler for ARC processors or it's just a random config you're experimenting with?

I need to build a bare-metal Fortran compiler for ARC.

@jian256384
Copy link
Author

Not quite right. Newlib only has a crt0.o for some configurations. For example x86_64-elf has a similar problem.

May I ask what modifications I need to make to achieve the correct configuration?

@QBos07
Copy link
Contributor

QBos07 commented Feb 9, 2024

  1. Enable the rescue shell
  2. run it until it crashes
  3. create a crt0.o in the sysroot under lib (maybe just touch works else you need to compile somthing with the _start that calls main; use assembler)
  4. Re-run the failed command
  5. exit the rescue shell inducation that the build can go on

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

No branches or pull requests

3 participants