-
-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate actions needed to build a package #1957
Comments
GoCompilePkg will be a replacement for GoCompile and several other actions. It will consolidate all the work of building a Go archive into a single Bazel action: it will run the Go compiler, the C/C++ compilers, the assembler, cgo, coverage, nogo, and pack all as one action. This should reduce sandboxing overhead for local configurations and file transfer overhead for remote configurations. This change introduces a very limited version of GoCompilePkg with most of the above functionality marked "TODO". It can only run the Go compiler. emit_archive uses this action for archives that don't require any other features. Updates bazel-contrib#1957
GoCompilePkg will be a replacement for GoCompile and several other actions. It will consolidate all the work of building a Go archive into a single Bazel action: it will run the Go compiler, the C/C++ compilers, the assembler, cgo, coverage, nogo, and pack all as one action. This should reduce sandboxing overhead for local configurations and file transfer overhead for remote configurations. This change introduces a very limited version of GoCompilePkg with most of the above functionality marked "TODO". It can only run the Go compiler. emit_archive uses this action for archives that don't require any other features. Updates bazel-contrib#1957
GoCompilePkg will be a replacement for GoCompile and several other actions. It will consolidate all the work of building a Go archive into a single Bazel action: it will run the Go compiler, the C/C++ compilers, the assembler, cgo, coverage, nogo, and pack all as one action. This should reduce sandboxing overhead for local configurations and file transfer overhead for remote configurations. This change introduces a very limited version of GoCompilePkg with most of the above functionality marked "TODO". It can only run the Go compiler. emit_archive uses this action for archives that don't require any other features. Updates bazel-contrib#1957
GoCompilePkg will be a replacement for GoCompile and several other actions. It will consolidate all the work of building a Go archive into a single Bazel action: it will run the Go compiler, the C/C++ compilers, the assembler, cgo, coverage, nogo, and pack all as one action. This should reduce sandboxing overhead for local configurations and file transfer overhead for remote configurations. This change introduces a very limited version of GoCompilePkg with most of the above functionality marked "TODO". It can only run the Go compiler. emit_archive uses this action for archives that don't require any other features. Updates #1957
@steeve #2027 is finally, finally merged. Would you mind trying it out some time in the next couple weeks? cgo is pretty much rewritten, and you're making the most extensive use of cgo that I know of. We're still using the old cgo code when |
Good job! I'm on the fence with regards to having everything into one action. It sure does help for remote builds, but I'm not sure how it stands with regards to caching and incremental builds ? |
I don't think this should affect caching or incremental builds too much. If a source file changes for a package, all the actions for that package (previously many, now one) need to be re-run. One case that might be slower is if a package has several C/C++/ObjC sources that take a long time to compile. If a .go file changes, or if an imported package changes, those will get recompiled. I think I'd recommend pulling those into an explicit separate |
That's a fair point indeed. So I've managed to make our Android library build with the following changes, which I'm not sure is the correct one, but gets the job done: diff --git a/go/tools/builders/filter.go b/go/tools/builders/filter.go
index 5771b580..7c1f3bd7 100644
--- a/go/tools/builders/filter.go
+++ b/go/tools/builders/filter.go
@@ -100,7 +100,7 @@ func readFileInfo(bctx build.Context, input string, needPackage bool) (fileInfo,
fi.ext = mExt
case ".s":
fi.ext = sExt
- case ".h":
+ case ".h", ".hh", ".hpp", ".hxx":
fi.ext = hExt
default:
return fileInfo{}, fmt.Errorf("unrecognized file extension: %s", ext) All in all, the change in build time is definitely noticeable on Android builds! Sandboxing the Android SDK and NDK isn't free. Good job jay ! Now let's see why the iOS isn't building. |
Ok so the build failures on iOS are happening due to
|
The correct kwargs["copts"] = copts + select({
"@co_znly_rules_gomobile//platform:ios": [
"-x objective-c",
"-fmodules",
"-fobjc-arc",
],
"//conditions:default": [],
}) Which is weird that they are not picked up ? Here are the flags for the action:
As you can see, |
Also, the problem I see with emulating objc with
Note that this is already the case since today the |
Actually @jayconrod, I think we can simply use the objc actions directly https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl#L115-L120 and get the command lines. They were added by bazelbuild/bazel@f451b79 |
Also, I think you might want to use the EDIT: actually, they were added later by bazelbuild/bazel@f147608 |
So I went ahead and tried to display the command line for the I'm seeing several possibilities:
|
Also, |
Ok so the iOS problem error was due to a missing That said, the objc problem I had in #1957 (comment) is still there. |
(Sorry I haven't responded to this yet. I'm trying to get some changes into cmd/go before the 1.13 freeze next week, and we're pretty swamped at the moment.) |
No worries! I'll send a PR if I get to working on that. |
PR opened at #2045 |
…#2027) GoCompilePkg will be a replacement for GoCompile and several other actions. It will consolidate all the work of building a Go archive into a single Bazel action: it will run the Go compiler, the C/C++ compilers, the assembler, cgo, coverage, nogo, and pack all as one action. This should reduce sandboxing overhead for local configurations and file transfer overhead for remote configurations. This change introduces a very limited version of GoCompilePkg with most of the above functionality marked "TODO". It can only run the Go compiler. emit_archive uses this action for archives that don't require any other features. Updates bazel-contrib#1957
Hey @steeve, I'd like to understand what Objective C support is needed on the new My vision for this is that If this is too inconvenient, we could continue having a Here's what I have so far:
Please let me know if I'm missing anything you know of. After the stuff above is done, I'll ask you to check that this works in your build before removing anything. |
That looks like a good plan.
The main problem though, used to be that the generated This may not look like a big deal, but it's would actually be pretty useful when calling custom |
Also, I see |
Do you have anything that's using the generated I don't think I understood why you needed Go rules to emit the That's not quite a clean interface and probably needs more thought, but for C++ at least, |
Objective C and C++ sources may now be compiled directly with go_library, go_binary, and go_test without needing to use the cgo legacy wrapper. The cpp toolchain must provide a compiler thats supports these languages. Appropriate flags will be passed to the compiler for each language, but no additional objcopts, objcxxopts attributes are provided. These are meant to accomodate CGO_CFLAGS, CGO_CXXFLAGS, and there is are no CGO_MFLAGS, CGO_MMFLAGS directives. These attributes can be added if necessary though. Updates bazel-contrib#1957
Objective C and C++ sources may now be compiled directly with go_library, go_binary, and go_test without needing to use the cgo legacy wrapper. The cpp toolchain must provide a compiler thats supports these languages. Appropriate flags will be passed to the compiler for each language, but no additional objcopts, objcxxopts attributes are provided. These are meant to accomodate CGO_CFLAGS, CGO_CXXFLAGS, and there is are no CGO_MFLAGS, CGO_MMFLAGS directives. These attributes can be added if necessary though. Updates #1957
Closing this at last.
|
Currently, we define separate actions for:
cc_library
,cc_binary
).We should consolidate all this functionality into a single action. This should reduce set up / tear down overhead in both local configurations (sandboxing) and remote configurations (file transfer).
Perhaps more importantly, cgo will be much easier to maintain if we move it out of loading / analysis phases into execution. Previously, we needed cgo logic to be in loading / analysis because we needed to compile generated C code with
cc_library
/cc_binary
rules. Bazel now gives us enough information to run the C compiler on our own.The text was updated successfully, but these errors were encountered: