Allow .S files in C++ Starlark cc_common.compile.#13155
Closed
jin wants to merge 1 commit intobazelbuild:masterfrom
Closed
Allow .S files in C++ Starlark cc_common.compile.#13155jin wants to merge 1 commit intobazelbuild:masterfrom
jin wants to merge 1 commit intobazelbuild:masterfrom
Conversation
.S files are (typically handwritten) assembly files that require preprocessing, compared to their lower-capital .s counterparts that can be compiled directly into object files. Native cc_library rules already allow .S files in srcs [1]. However, the Starlark cc_common.compile srcs argument doesn't accept them. This change adds .S files to the list of valid srcs for cc_common.compile. This is required for building AOSP, as there are handwritten source files in Android's libc with the .S extension [2] that will be compiled through Starlark C++ rules, e.g. directly into .o files. [1]: https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java;l=280;drc=35de1e352459729f95d552b6ae5af9ce7d00a943 [2]: https://cs.android.com/search?q=f:%5C.S$&sq=
Member
Author
|
@oquenchil Imported this PR, happy to iterate here or in the internal CL. |
philwo
pushed a commit
that referenced
this pull request
Apr 19, 2021
.S files are (typically handwritten) assembly files that require preprocessing, compared to their lower-capital .s counterparts that can be compiled directly into object files. Native cc_library rules already allow .S files in srcs [1]. However, the Starlark cc_common.compile srcs argument doesn't accept them. This change adds .S files to the list of valid srcs for cc_common.compile. This is required for building AOSP, as there are handwritten source files in Android's libc with the .S extension [2] that will be compiled through Starlark C++ rules, e.g. directly into .o files. [1] https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java;l=280;drc=35de1e352459729f95d552b6ae5af9ce7d00a943 [2] https://cs.android.com/search?q=f:%5C.S$&sq= Closes #13155. PiperOrigin-RevId: 361106705
sfX-bot
pushed a commit
to AXP-OS/platform_build_bazel
that referenced
this pull request
Jun 22, 2025
Instead of doing a full link with cc_library, this CL replaces the native.cc_library call to an actual rule that calls into cc_common and runs a compile, not link, on the input files, and returns a DefaultInfo containing only the objects in compilation outputs. The previous implementation would have built a static archive, which was wrong. This requires bazelbuild/bazel#13155 to be merged first, since the cc_common.compile API today doesn't accept .S files as inputs, which are valid assembly files. $ bazel-dev --bazelrc=build/bazel/linux.bazelrc cquery 'kind(_cc_object, //bionic/libc:all)' --output=starlark --starlark:expr="str(target.label) + ' ' + ' '.join([f.basename for f in target.files.to_list()])" //bionic/libc:crtbegin_dynamic crtbegin.o crtbrand.o //bionic/libc:crtbegin_dynamic1 crtbegin.o //bionic/libc:crtbegin_so crtbegin_so.o crtbrand.o //bionic/libc:crtbegin_so1 crtbegin_so.o //bionic/libc:crtbegin_static crtbegin.o crtbrand.o //bionic/libc:crtbegin_static1 crtbegin.o //bionic/libc:crtbrand crtbrand.o //bionic/libc:crtend_android crtend.o //bionic/libc:crtend_so crtend_so.o //bionic/libc:libseccomp_gen_syscall_nrs_arm gen_syscall_nrs.o //bionic/libc:libseccomp_gen_syscall_nrs_arm64 gen_syscall_nrs.o //bionic/libc:libseccomp_gen_syscall_nrs_x86 gen_syscall_nrs_x86.o //bionic/libc:libseccomp_gen_syscall_nrs_x86_64 gen_syscall_nrs_x86_64.o Test: build/bazel/scripts/milestone-2/demo.sh full Test: go tests Change-Id: If1944afb66c756a656399972711491ba489410ec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.S files are (typically handwritten) assembly files that require
preprocessing, compared to their lower-capital .s counterparts that can
be compiled directly into object files.
Native cc_library rules already allow .S files in srcs [1]. However, the
Starlark cc_common.compile srcs argument doesn't accept them. This
change adds .S files to the list of valid srcs for cc_common.compile.
This is required for building AOSP, as there are handwritten source files in
Android's libc with the .S extension [2] that will be compiled through
Starlark C++ rules, e.g. directly into .o files.
[1] https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java;l=280;drc=35de1e352459729f95d552b6ae5af9ce7d00a943
[2] https://cs.android.com/search?q=f:%5C.S$&sq=