Vanilla Face
Vanilla Face

Reputation: 916

clang - build with default flags

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?

Upvotes: 0

Views: 549

Answers (2)

echristo
echristo

Reputation: 1727

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 $@

Upvotes: 1

usr1234567
usr1234567

Reputation: 23294

Use a makefile instead. Or create an alias in your bashrc. Everything else are crude hacks which I wouldn't use.

Upvotes: 0

Related Questions