0
votes

I want to do cross-compilation of following source file (Foo.cpp)

#include <cstdint>

int Foo()
{
   uint32_t bar = 0;

   return bar;  
}

with i686-w64-mingw32 and arm-none-eabi on a Windows 10 system. Therefore I use following batch file

@echo off

set "PATH=C:/MinGW/i686-8.1.0-release-win32-dwarf-rt_v6-rev0/bin;%PATH%"
set "PATH=C:/GNU-Tools-ARM-Embedded/7-2018-q2-update/bin;%PATH%"
set "PATH=C:/LLVM/7.0.0/bin;%PATH%"

clang++ ^
        -c ^
        -std=gnu++14 ^
        -v ^
        -target i686-w64-mingw32 ^
        Foo.cpp ^
        -o Foo.obj

@echo on
REM
REM 
REM 
REM 
REM
@echo off

clang++ ^
        -c ^
        -std=gnu++14 ^
        -v ^
        -target arm-none-eabi ^
        -march=armv6-m ^
        -mcpu=cortex-m0 ^
        -mthumb ^
        -msoft-float ^
        -mfloat-abi=soft ^
        --sysroot=C:/GNU-Tools-ARM-Embedded/7-2018-q2-update ^
        Foo.cpp ^
        -o Foo.o

pause

This produces following output

clang version 7.0.0 (tags/RELEASE_700/final)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: C:\LLVM\7.0.0\bin
 "C:\\LLVM\\7.0.0\\bin\\clang++.exe" -cc1 -triple i686-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name Foo.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file "c:\\Users\\Zlatan\\MKS\\Test\\Foo.gcno" -resource-dir "C:\\LLVM\\7.0.0\\lib\\clang\\7.0.0" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include\\c++" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include\\c++\\i686-w64-mingw32" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include\\c++\\backward" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include\\c++\\8.1.0" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include\\c++\\8.1.0\\i686-w64-mingw32" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include\\c++\\8.1.0\\backward" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\include\\c++\\8.1.0" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\include\\c++\\8.1.0\\i686-w64-mingw32" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\include\\c++\\8.1.0\\backward" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\lib\\gcc\\i686-w64-mingw32\\8.1.0\\include\\c++" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\lib\\gcc\\i686-w64-mingw32\\8.1.0\\include\\c++\\i686-w64-mingw32" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\lib\\gcc\\i686-w64-mingw32\\8.1.0\\include\\c++\\backward" -internal-isystem "C:\\LLVM\\7.0.0\\lib\\clang\\7.0.0\\include" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32/sys-root/mingw/include" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\i686-w64-mingw32\\include" -internal-isystem "C:\\MinGW\\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\\include" -std=gnu++14 -fdeprecated-macro -fdebug-compilation-dir "c:\\Users\\Zlatan\\MKS\\Test" -ferror-limit 19 -fmessage-length 227 -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdwarf-exceptions -fdiagnostics-show-option -fcolor-diagnostics -o Foo.obj -x c++ Foo.cpp
clang -cc1 version 7.0.0 based upon LLVM 7.0.0 default target x86_64-pc-win32
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include\c++"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include\c++\i686-w64-mingw32"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include\c++\backward"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include\c++\8.1.0"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include\c++\8.1.0\i686-w64-mingw32"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include\c++\8.1.0\backward"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\include\c++\8.1.0"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\include\c++\8.1.0\i686-w64-mingw32"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\include\c++\8.1.0\backward"
ignoring nonexistent directory "C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32/sys-root/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\lib\gcc\i686-w64-mingw32\8.1.0\include\c++
 C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\lib\gcc\i686-w64-mingw32\8.1.0\include\c++\i686-w64-mingw32
 C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\lib\gcc\i686-w64-mingw32\8.1.0\include\c++\backward
 C:\LLVM\7.0.0\lib\clang\7.0.0\include
 C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\i686-w64-mingw32\include
 C:\MinGW\i686-8.1.0-release-win32-dwarf-rt_v6-rev0\include
End of search list.

c:\Users\Zlatan\MKS\Test>REM

c:\Users\Zlatan\MKS\Test>REM

c:\Users\Zlatan\MKS\Test>REM

c:\Users\Zlatan\MKS\Test>REM

c:\Users\Zlatan\MKS\Test>REM
clang version 7.0.0 (tags/RELEASE_700/final)
Target: arm-none--eabi
Thread model: posix
InstalledDir: C:\LLVM\7.0.0\bin
 "C:\\LLVM\\7.0.0\\bin\\clang++.exe" -cc1 -triple thumbv6m-none--eabi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name Foo.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m0 -target-feature +soft-float -target-feature +soft-float-abi -target-feature -crc -target-feature -dsp -target-feature -ras -target-feature -dotprod -target-feature -hwdiv-arm -target-feature -hwdiv -target-feature -fp-only-sp -target-feature -d16 -target-feature -vfp2 -target-feature -vfp3 -target-feature -fp16 -target-feature -vfp4 -target-feature -fp-armv8 -target-feature -neon -target-feature -crypto -target-feature +strict-align -target-abi aapcs -msoft-float -mfloat-abi soft -fallow-half-arguments-and-returns -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file "c:\\Users\\Zlatan\\MKS\\Test\\Foo.gcno" -resource-dir "C:\\LLVM\\7.0.0\\lib\\clang\\7.0.0" -isysroot C:/GNU-Tools-ARM-Embedded/7-2018-q2-update -internal-isystem "C:/GNU-Tools-ARM-Embedded/7-2018-q2-update\\include\\c++\\v1" -internal-isystem "C:\\LLVM\\7.0.0\\lib\\clang\\7.0.0\\include" -internal-isystem "C:/GNU-Tools-ARM-Embedded/7-2018-q2-update\\include" -std=gnu++14 -fdeprecated-macro -fdebug-compilation-dir "c:\\Users\\Zlatan\\MKS\\Test" -ferror-limit 19 -fmessage-length 227 -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o Foo.o -x c++ Foo.cpp -faddrsig
clang -cc1 version 7.0.0 based upon LLVM 7.0.0 default target x86_64-pc-win32
ignoring nonexistent directory "C:/GNU-Tools-ARM-Embedded/7-2018-q2-update\include\c++\v1"
ignoring nonexistent directory "C:/GNU-Tools-ARM-Embedded/7-2018-q2-update\include"
ignoring duplicate directory "C:\LLVM\7.0.0\lib\clang\7.0.0\include"
#include "..." search starts here:
#include <...> search starts here:
 C:\LLVM\7.0.0\lib\clang\7.0.0\include
End of search list.
Foo.cpp:1:10: fatal error: 'cstdint' file not found
#include <cstdint>
         ^~~~~~~~~
1 error generated.

So for the i686-w64-mingw32 it's enough to put the location of the compiler to the path, but for arm-none-eabi the clang compiler can't find the cross-compilation headers.

Does somebody know how to configure clang for arm-none-eabi?

Why does this following happen?

Target: arm-none--eabi

Shouldn't it be?

Target: arm-none-eabi

Thanks!

Zlatan

1
ignoring nonexistent directory "C:/GNU-Tools-ARM-Embedded/7-2018-q2-update\include\c++\v1" please make sure this directory exist. This directory should contain c++ header files/ - hare1039
The folder didn't exist. I use the toolchain from "developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/…" and didn't change anything in the folder structure (same as for the i686-w64-mingw32 compiler) - ge45mue

1 Answers

1
votes

I'm a bit late to the party but here are my two cents anyway:

The --sysroot option should be:

--sysroot=C:/GNU-Tools-ARM-Embedded/7-2018-q2-update/arm-none-eabi

You are missing the /arm-none-eabi part at the end. Clang looks for the directories bin, lib and include which are in the arm-none-eabi subdirectory of the toolchain (see the documentation here).

This should fix the "ignoring nonexistent directory" errors and the fatal error because of the missing standard library.