ELLCC is based on clang/LLVM of course. Previously I mentioned that I was experimenting with YAML based config files for the compiler driver. When I made that post and subsequently, several people had objections to the approach because it potentially required reading a file each time the compiler is involked and that it would make the already complicated driver code even more complicated. It came up again today in the LLVM mailing list and it got me to thinking that maybe another real world example might help.
I used MinGW to cross compile ELLCC for Windows hosts. I started to wonder what an ELLCC config file might look like for using clang to cross compile for Windows instead. I came up with this as a first cut example:
# based_on `i386-ellcc-linux' # based_on `ellcc-linux' --- based_on: '' global: static_default: true compiler: options: - -target i386-ellcc-win32 # - -no-integrated-as c_include_dirs: - /usr/lib64/gcc/i686-w64-mingw32/4.8.4/include - /usr/lib64/gcc/i686-w64-mingw32/4.8.4/include-fixed - /usr/i686-w64-mingw32/sys-root/mingw/include cxx_include_dirs: - '$R/include/c++' assembler: exe: '/usr/lib64/gcc/i686-w64-mingw32/4.8.4/../../../../i686-w64-mingw32/bin/as' output: - '-o $O' linker: exe: '/usr/libexec/gcc/i686-w64-mingw32/4.8.4/collect2' output: - '-o $O' start: #- -e _start opt_static: - -Bstatic opt_rdynamic: - -export-dynamic opt_dynamic: - -Bdynamic opt_shared: - -shared opt_notshared: - -dynamic-linker /usr/libexec/ld.so opt_pthread: - -pthread options: - -m i386pe static_crt1: '/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o' dynamic_crt1: '$R/lib/i386-linux-eng/Scrt1.o' crtbegin: '/usr/lib64/gcc/i686-w64-mingw32/4.8.4/crtbegin.o' crtend: '/usr/lib64/gcc/i686-w64-mingw32/4.8.4/crtend.o' library_paths: - '-L/usr/lib64/gcc/i686-w64-mingw32/4.8.4' - '-L/usr/lib64/gcc/i686-w64-mingw32/4.8.4/../../../../i686-w64-mingw32/lib/../lib' - '-L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib' - '-L/usr/lib64/gcc/i686-w64-mingw32/4.8.4/../../../../i686-w64-mingw32/lib' - '-L/usr/i686-w64-mingw32/sys-root/mingw/lib' cxx_libraries: - '-lc++' - -lm profile_libraries: - -lprofile_rt c_libraries: - '-lmingw32' - '-lgcc' - '-lgcc_eh' - '-lmoldname' - '-lmingwex' - '-lmsvcrt' - '-ladvapi32' - '-lshell32' - '-luser32' - '-lkernel32' - '-lmingw32' - '-lgcc' - '-lgcc_eh' - '-lmoldname' - '-lmingwex' - '-lmsvcrt' ...
I called it i386-w64-mingw32, and, Hey Presto! a Windows cross compiler on my Linux box.
[~] dev% cat main.c #include <stdio.h> int main() { printf("hello world\n"); } [~] dev% ~/ellcc/bin/ecc -target i386-w64-mingw32 main.c [~] dev% ./a.exe fixme:winediag:start_process Wine-Compholio is a Wine testing version containing experimental patches. fixme:winediag:start_process Please don't report bugs at winehq.org and use our issue tracker instead: fixme:winediag:start_process https://github.com/compholio/wine-compholio/issues hello world [~] dev% file a.exe a.exe: PE32 executable (console) Intel 80386, for MS Windows [~] dev%
Wow, this is great stuff! Are you thinking of building this into a future ellcc release? A universal toolchain sounds great.
Hi Brent,
Yes, I think this would be a cool addition for a future release. What I’d like to do is build ELLCC’s version of binutils, especially ecc-ld to support Windows binary format and do a build with it. That way, MinGW support would only need the header files and libraries.
-Rich