I want to use clang for cross compiling. I've found out that it seems very easy, I can specify architectures/includes etc. just as I invoke clang directly.
However, I don't want to keep passing those flags, I'd rather compile clang so that it would have these by default.
That is, when I invoke clang just as clang++ main.cpp
I'd like it to become clang++ -i686-w64-mingw32 -target-isystem=/usr/some/path main.cpp
etc, how can I do that?
Asked
Active
Viewed 442 times
0

Soumyaansh
- 8,626
- 7
- 45
- 45

Vanilla Face
- 908
- 1
- 7
- 17
-
You can do that in several ways, such as using `makefile`, defining your `alias` in whatever shell you prefer, or you can write your own script file that gives the compiler the designated options for you. Maybe time for you to have some build system. – Dean Seo Dec 04 '15 at 07:08
2 Answers
1
You can use a response file to do this sort of thing, it's also how you'd avoid command lines that are too long for your OS.
Something like:
clang @target_cmds.inc -c foo.c
will likely work for you.
(In addition to the earlier comments of some build system hackery or an alias, you could also define clang as a wrapper script that you invoke that does the same thing, e.g.:
#!/bin/sh
clang -target i686-w64-mingw32 -target-isystem=/usr/some/path $@

echristo
- 1,687
- 10
- 8
0
Use a makefile instead. Or create an alias in your bashrc. Everything else are crude hacks which I wouldn't use.

usr1234567
- 21,601
- 16
- 108
- 128