[SERVER-81425] Automatically detect C files in bazel toolchain Created: 25/Sep/23 Updated: 18/Dec/23 Resolved: 08/Nov/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.3.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Zack Winter | Assignee: | Zack Winter |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Build
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
With the current toolchain *.c files are being compiled with g+/clang+ which define the macro `__cplusplus`. This is incorrect and breaks the ability to properly compile a large number of C targets. Modify the toolchain to detect .c files and instead compile them with gcc/clang. |
| Comments |
| Comment by Githook User [ 08/Nov/23 ] |
|
Author: {'name': 'Zack Winter', 'email': 'zack.winter@mongodb.com', 'username': 'zackwintermdb'}Message: |
| Comment by Githook User [ 06/Nov/23 ] |
|
Author: {'name': 'Zack Winter', 'email': 'zack.winter@mongodb.com', 'username': 'zackwintermdb'}Message: |
| Comment by Zack Winter [ 19/Oct/23 ] |
|
In master we're relying on a macro around the native `cc_library` right now so I don't think there's a way to select a toolchain based on the extension of each source code as-is: https://github.com/mongodb/mongo/blob/master/bazel/mongo_src_rules.bzl#L5 If we switch to implementing our own version of `cc_library/program/etc` like in the POC we can select the toolchain based off of the extension. Do you think we won't be able to rely on the native versions of these to support all of the features we need? It would be great if we could rely on the built in bazel cc rules to do a lot of the manual work, but I'm not sure how far defining our own toolchain config will get us. |
| Comment by Zack Winter [ 19/Oct/23 ] |
|
Notes from meeting with daniel.moody@mongodb.com - we will want to require this before flipping the switch on requiring bazel since there are subtle differences between gcc/clang & g+/clang+ We can do this either by:
The second is a bit messy since it's yet another dimension of toolchain configs, which is already pretty huge (arch, OS, compiler), but it's a much simpler implementation. |