Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for compiling BoringSSL with sanitizers (ASan, MSan, or TSan) when the Dart runtime uses them, which automatically triggers building from source. It also enables the 'OPENSSL_SMALL' compilation flag to reduce the tree-shaken library size at the cost of slower P-256 operations. The review feedback suggests simplifying the build mode override logic in 'pkgs/boring/hook/build.dart' to leverage Dart's flow analysis and eliminate the need for a null assertion operator on the sanitizer variable.
56ca107 to
a000c1c
Compare
PR HealthPublish ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Unused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with
Coverage
|
| File | Coverage |
|---|---|
| pkgs/boring/hook/build.dart | 💔 Not covered |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
| sanitizer != null && buildOptions.buildMode == BuildModeEnum.fetch | ||
| ? BuildModeEnum.checkout | ||
| : buildOptions.buildMode; | ||
| if (buildMode != buildOptions.buildMode) { |
There was a problem hiding this comment.
What kind of failure do you get if you don't have the toolchain to support this? I'm worried that this kind of optionality with fallbacks is making the package more complex than it needs to be.
There was a problem hiding this comment.
You mean in case I specify a sanitizer but don't want to build? We could just throw here.
There was a problem hiding this comment.
If you throw, you cannot run any tests even ones that don't use boringssl in your project at all if package:boring is in your dependency graph.
Fallbacks is a bad idea for sanitizers. If you don't support sanitizers you should fail the hook. Sanitizers running with half instrumented code give all kinds of weird results.
| 'CMAKE_INSTALL_PREFIX': installDir.toFilePath(), | ||
| // The Dart SDK's sanitizer runtimes come from Clang, so compile with | ||
| // Clang instead of the compiler of the build config's toolchain. | ||
| if (sanitizer != null) ...{ |
There was a problem hiding this comment.
This seems fragile. Maybe build hooks can help with this somehow? @dcharkes
There was a problem hiding this comment.
Why do we need this?
The Dart SDK doesn't provide toolchains at all in the cCompilerConfig? What build config are you referring to?
There was a problem hiding this comment.
We use native_toolchain_cmake, which does pass a toolchain. But this is probably not the right place to make that fix...
There was a problem hiding this comment.
Are you saying native_toolchain_cmake has a bug when you specify santizers? then it should be fixed there.
|
|
||
| # Symbol prefixing: all BoringSSL symbols become bssl_dart_<symbol> | ||
| add_definitions(-DBORINGSSL_PREFIX=bssl_dart) | ||
| # Smaller precomputed tables, mainly for P-256, in exchange for slower |
There was a problem hiding this comment.
The size difference didn't seem very important (~15%?)
There was a problem hiding this comment.
Well I think 15% is a lot.. But happy to push optimizations to a later stage.
There was a problem hiding this comment.
When compiling from source, you could make it configurable via a user-define.
For precompiled, every combination of options would lead to an exponential set of predefined dylibs, so we have to chose a default.
| @@ -1,4 +1,11 @@ | |||
| ## 0.4.3-wip | |||
| - BoringSSL is compiled with `OPENSSL_SMALL`, which for example makes the | |||
There was a problem hiding this comment.
I think that this should be two changes:
- sanitizer support
- OPENSSL_SMALL support
The build hook ignored the `sanitizer` of the build config, so for example `dart test -p vm-asan` loaded an uninstrumented BoringSSL, and package:webcrypto's ASan CI job (google/webcrypto.dart#424) no longer checks BoringSSL since it moved to package:boring. - With a sanitizer, compile BoringSSL with it and Clang, like package:webcrypto's build hook did. The prebuilt libraries aren't instrumented, so the `fetch` build mode builds from source in that case. - Add an `asan` CI job. - List BoringSSL's `.inc` files as dependencies of the `checkout` build, like google/webcrypto.dart#429.
a000c1c to
e241a3e
Compare
Note
This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.
Sanitizers
The build hook ignored
input.config.code.sanitizer. Sodart test -p vm-asanloaded uninstrumented BoringSSL, andpackage:webcrypto's ASan CI job (google/webcrypto.dart#424) no longer checks BoringSSL since it moved topackage:boring. Now, like webcrypto's old build hook:checkoutbuild compiles with Clang and-fsanitize=address|memory|thread, viaBSSL_DART_SANITIZERinsrc/CMakeLists.txt.fetchbuild mode builds from source in that case, because the prebuilt libraries aren't instrumented. It never uses an uninstrumented library with a sanitizer. If CMake, Ninja, or Clang are missing, the hook fails.asanCI job runstest/boring_test.dartwith-p vm-asan. Locally, it passes, and the built library references 41__asan_*symbols, compared with none without a sanitizer..incbuild inputsBoringSSL has 91
.incfiles, such ascrypto/fipsmodule/*.cc.inc, which thecheckoutbuild didn't list as dependencies, so it didn't rebuild when they changed. google/webcrypto.dart#429 fixed the same issue.Testing
Rebased on 0.5.1-wip. Locally on Linux x64:
dart test(34 passed, 5 skipped) anddart test -c cli -p vm-asan test/boring_test.dart.