Skip to content

Support cross compilation when compiler given as path#491

Open
mtvec wants to merge 1 commit intodistcc:masterfrom
mtvec:rewrite-compiler-paths
Open

Support cross compilation when compiler given as path#491
mtvec wants to merge 1 commit intodistcc:masterfrom
mtvec:rewrite-compiler-paths

Conversation

@mtvec
Copy link
Copy Markdown

@mtvec mtvec commented Oct 8, 2023

distcc supports cross compilation by rewriting the compiler binary (for GCC) or adding the -target flag (for Clang). However, this currently only works when the compiler is given without a full path. That is, when the compiler is given as, for example, /usr/bin/gcc, nothing gets rewritten.

This patch adds support for full paths by by matching on the compiler's basename instead of its full path in argv[0].

The implementation in this patch rewrites paths as follows:

  • /path/to/clang -> /path/to/clang -target ...
  • /path/to/gcc -> <target>-gcc

I'm not quite sure if this difference in behavior between GCC and Clang is wanted. In particular, it might be better to rewrite the GCC case to /path/to/<target>-gcc. However,this would make the implementation a bit more complex so I'd like to discuss this before implementing it.

distcc supports cross compilation by rewriting the compiler binary (for
GCC) or adding the `-target` flag (for Clang). However, this currently
only works when the compiler is given without a full path. That is, when
the compiler is given as, for example, `/usr/bin/gcc`, nothing gets
rewritten.

This patch adds support for full paths by by matching on the compiler's
basename instead of its full path in `argv[0]`.

The implementation in this patch rewrites paths as follows:
- `/path/to/clang` -> `/path/to/clang -target ...`
- `/path/to/gcc` -> `<target>-gcc`

I'm not quite sure if this difference in behavior between GCC and Clang
is wanted. In particular, it might be better to rewrite the GCC case to
`/path/to/<target>-gcc`. However,this would make the implementation a
bit more complex so I'd like to discuss this before implementing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant