Windows-on-ARM-Experiments / mingw-woarm64-build

Workflows and build scripts for Windows on Arm64 GNU cross-compiler for `aarch64-w64-mingw32` target.
GNU General Public License v2.0
33 stars 4 forks source link

Builtin compiler options do not work when following README #201

Open sanderjo opened 2 months ago

sanderjo commented 2 months ago

the build.sh went well, PATH is set, but I get:

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ aarch64-w64-mingw32-gcc ../hello.c 
aarch64-w64-mingw32-gcc: fatal error: cannot execute ‘cc1’: posix_spawnp: No such file or directory
compilation terminated.

cc1 is there in subdirs:

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ find . -type f -executable -print | grep cc1
./libexec/gcc/aarch64-w64-mingw32/15.0.0/cc1
./lib/libcc1.so.0.0.0
./lib/gcc/aarch64-w64-mingw32/15.0.0/cc1plus
./lib/gcc/aarch64-w64-mingw32/15.0.0/cc1
./lib/gcc/aarch64-w64-mingw32/15.0.0/plugin/libcc1plugin.la
./lib/gcc/aarch64-w64-mingw32/15.0.0/plugin/libcc1plugin.so.0.0.0
./lib/libcc1.la
sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ printenv PATH
~/cross-aarch64-w64-mingw32-msvcrt/bin:/home/sander/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

So what now?

Blackhex commented 2 months ago

Thank you for the report. It seems that aarch64-w64-mingw32-gcc cannot find cc1 in the PATH. This should not happen so we will try to reproduce and investigate the issue. For now, adding ./libexec/gcc/aarch64-w64-mingw32/15.0.0 to PATH should help.

sanderjo commented 2 months ago

Thanks for the quick answer.

ll ~/cross-aarch64-w64-mingw32-msvcrt/libexec/gcc/aarch64-w64-mingw32/15.0.0/
export PATH="~/cross-aarch64-w64-mingw32-msvcrt/libexec/gcc/aarch64-w64-mingw32/15.0.0/:$PATH"
sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ printenv PATH
~/cross-aarch64-w64-mingw32-msvcrt/libexec/gcc/aarch64-w64-mingw32/15.0.0/:~/cross-aarch64-w64-mingw32-msvcrt/bin:/home/sander/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Looks good?

But still

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ aarch64-w64-mingw32-gcc ../hello.c
aarch64-w64-mingw32-gcc: fatal error: cannot execute ‘cc1’: posix_spawnp: No such file or directory
compilation terminated.

The strange thing: cc1 is found ... altough I'm not sure this is aarch64-w64 one ...

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ cc1 --help | head
The following options are specific to just the language Ada:
  -fdump-scos                       [available in Ada]

The following options are specific to just the language AdaSCIL:
 None found.  Use --help=AdaSCIL to show *all* the options supported by the AdaSCIL front-end.

The following options are specific to just the language AdaWhy:
 None found.  Use --help=AdaWhy to show *all* the options supported by the AdaWhy front-end.

The following options are specific to just the language C:

And which produces no output?

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ which cc1
sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ 
sanderjo commented 2 months ago

I read -B could help, but

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ aarch64-w64-mingw32-gcc -B ~/cross-aarch64-w64-mingw32-msvcrt/libexec/gcc/aarch64-w64-mingw32/15.0.0/ ../hello.c
../hello.c:1:19: error: no include path in which to search for stdio.h
    1 | #include <stdio.h>
      |                   ^
../hello.c: In function 'main':
../hello.c:4:4: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    4 |    printf("Hello, World!");
      |    ^~~~~~
../hello.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
  +++ |+#include <stdio.h>
    1 | #include <stdio.h>
../hello.c:4:4: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
    4 |    printf("Hello, World!");
      |    ^~~~~~
../hello.c:4:4: note: include '<stdio.h>' or provide a declaration of 'printf'
Blackhex commented 2 months ago

Hmm, interesting. It seems that builtin compiler options do not work. Don't know why yet but the other error could be fixed with -I/home/sander/cross-aarch64-w64-mingw32-msvcrt/include.

What is your host operating system / UNIX environment?

sanderjo commented 2 months ago

Is this how -I should be used?

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ aarch64-w64-mingw32-gcc -B ~/cross-aarch64-w64-mingw32-msvcrt/libexec/gcc/aarch64-w64-mingw32/15.0.0/ -I /home/sander/cross-aarch64-w64-mingw32-msvcrt/include   ../hello.c
../hello.c:1:10: fatal error: stdio.h: No such file or directory
    1 | #include <stdio.h>
      |          ^~~~~~~~~
compilation terminated.

Plain Ubuntu 22.04

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ 
sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ uname -a
Linux brixit 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:    22.04
Codename:   jammy
eukarpov commented 1 month ago

is it the same issue if it is called this way? ~/cross-aarch64-w64-mingw32-msvcrt/aarch64-w64-mingw32-gcc ../hello.c

sanderjo commented 1 month ago

So ... hard-specifying the location inside the bin directory? With a bit different pathes ... that works:

sander@brixit:~$ ~/cross-aarch64-w64-mingw32-msvcrt/bin/aarch64-w64-mingw32-gcc ./hello.c -o hello_1234
sander@brixit:~$
sander@brixit:~$ file hello_1234
hello_1234: PE32+ executable (console) Aarch64, for MS Windows

and also

sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt/bin$ ./aarch64-w64-mingw32-gcc  ~/hello.c -o hello_2222
sander@brixit:~/cross-aarch64-w64-mingw32-msvcrt/bin$ file hello_2222
hello_2222: PE32+ executable (console) Aarch64, for MS Windows
eukarpov commented 1 month ago

It looks it can be reproduced on our side. Thanks for reporting this.