bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Document "magical" features with regards to various Apple CC toolchains

Open ahyangyi opened this issue 10 years ago • 4 comments

I'm adding a cc toolchain to support iOS compilation. However, Bazel looks at the target CPU name and decides it's an iOS toolchain and uses a different way to compile everything.

(The relevant code is at src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java)

It's probably justified if it somehow magically works. But no, Bazel still tries to link shared objects (?) for cc_library's and still tries to use the -Wl,@param_file syntax that the Apple ld doesn't seem to support. But yet I cannot set a flag to tell Bazel "No, my linker does not support @file syntax and you should not do that".

Could we have this hidden feature documented? I have absolutely no idea why Bazel is doing something special when I set the cpu of a toolchain to certain values, and why it doesn't actually work.

ahyangyi avatar Sep 05 '16 09:09 ahyangyi

Oops, I noticed that supports_param_files is an option in cc_toolchain. I was looking at the CROSSTOOL file which is why I didn't find this option.

Anyway, better document on Apple-specific cc features is still wanted. The current document doesn't say anything about using a cc_library with an apple toolchain at all.

ahyangyi avatar Sep 05 '16 10:09 ahyangyi

Were actively working on simplifying the multi-platform experience for the cc rules. The param files thing in particular is something we want to simplify.

calpeyser avatar Sep 19 '16 15:09 calpeyser

@calpeyser Could you elaborate a bit on your plans?

I've never found the param files hard to understand. They are a practical mechanism with simple defined behavior.

And as far as I know, the corresponding code in Bazel is also based on a simple principle: moving flags that are known to be OK to be moved together to the param file, leaving the remaining alone. One can easily reason about that. The code is also short enough to maintain.

I'm more concerned with various undocumented features, like when my cpu begins with ios Bazel suddenly compiles with different behaviors, or when building with -c opt Bazel produces .pic.a files while under other optimization levels Bazel produces .a files containing PIC object files. These are the real breakers for me.

ahyangyi avatar Sep 20 '16 05:09 ahyangyi

Closing as I'm guessing this is not an issue any longer after 4 years (given that a lot of things have changed regarding the rules and documentation). Please let us know otherwise.

jmmv avatar May 14 '20 16:05 jmmv