-
Notifications
You must be signed in to change notification settings - Fork 1
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
disable ubsan null checks with gcc #93
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## master #93 +/- ##
=======================================
Coverage 98.82% 98.82%
=======================================
Files 11 11
Lines 255 255
=======================================
Hits 252 252
Misses 3 3 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. I hate carrying patches. OK for now I guess.
do you want to merge this before #89?
…On Thu, Sep 28, 2023, 11:41 Gary Miguel ***@***.***> wrote:
***@***.**** approved this pull request.
Ugh. I hate carrying patches. OK for now I guess.
------------------------------
In WORKSPACE.bazel
<#93 (comment)>:
> +#
+# The patched cc_* rules adds the sanitize feature disable flags in `copts` only
+# for GCC + UBSan builds. As these are set in `user_compile_flags`, these
+# options follow `-fsanitize=undefined` when present.
+#
+# https://bazel.build/rules/lib/toplevel/cc_common#parameters_5
+#
+http_archive(
+ name = "rules_cc",
+ patch_args = ["-p1"],
+ patches = ["//toolchain:rules_cc-gcc-ubsan-no-sanitize-null.patch"],
+ #sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdx",
+ sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
+ strip_prefix = "rules_cc-0.0.9",
+ urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
+ #patches = ["//:third_party/google_benchmark.patch"],
remove
------------------------------
In WORKSPACE.bazel
<#93 (comment)>:
> +# (bootlin_toolchain below) as the sanitize feature disable flags will precede
+# `-fsanitize=undefined` from `--features=ubsan` and thus be ignored.
+#
+# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#id3
+#
+# The patched cc_* rules adds the sanitize feature disable flags in `copts` only
+# for GCC + UBSan builds. As these are set in `user_compile_flags`, these
+# options follow `-fsanitize=undefined` when present.
+#
+# https://bazel.build/rules/lib/toplevel/cc_common#parameters_5
+#
+http_archive(
+ name = "rules_cc",
+ patch_args = ["-p1"],
+ patches = ["//toolchain:rules_cc-gcc-ubsan-no-sanitize-null.patch"],
+ #sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdx",
remove
------------------------------
In toolchain/rules_cc-gcc-ubsan-no-sanitize-null.patch
<#93 (comment)>:
> @@ -0,0 +1,50 @@
+diff --git a/cc/defs.bzl b/cc/defs.bzl
+index a3acac7..53ee96e 100644
+--- a/cc/defs.bzl
++++ b/cc/defs.bzl
+@@ -46,6 +46,18 @@ def _add_tags(attrs, is_binary = False):
+
+ return attrs
+
++def _gcc_no_sanitize_null(attrs):
++ attrs["copts"] = (
++ attrs.get("copts") or [] +
get() takes a default as an optional second arg:
attrs.get("copts", [])
—
Reply to this email directly, view it on GitHub
<#93 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWT4J3FIN7YF7KZUIQITB3X4XAFHANCNFSM6AAAAAA5ISS56A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Use of GCC with UBSan and the null, returns-nonnull-attribute, nonnull-attribute checks will cause the compiler to reject valid code due to use of the underlying GCC option -fno-delete-null-pointer-checks. This commit patches rules_cc to disable these checks if a GCC compiler is used with the ubsan feature. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762#c2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962 This change is needed by #89. Change-Id: Ic0e5224850d8478aa92806a8f21248e979acce04
9db71f1
to
d1c8b2e
Compare
Use of GCC with UBSan and the null, returns-nonnull-attribute,
nonnull-attribute checks will cause the compiler to reject valid code
due to use of the underlying GCC option -fno-delete-null-pointer-checks.
This commit patches rules_cc to disable these checks if a GCC compiler
is used with the ubsan feature.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762#c2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962
This change is needed by #89.
Change-Id: Ic0e5224850d8478aa92806a8f21248e979acce04