Skip to content

Support enabling sanitizers easily #27190

Closed

Description

@jdm

Based on https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/sanitizer.html, I have successfully compiled Servo by adding -Zsanitizer=address to the rustflags field in my .servobuild, and using the following diff:

diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py
index 58ef42e68a..f2c9b0dc4a 100644
--- a/python/servo/build_commands.py
+++ b/python/servo/build_commands.py
@@ -645,6 +645,9 @@ class MachCommands(CommandBase):
         # given on the command line can override it
         opts = ["-Ztimings=info"] + opts

+        if "-Zsanitizer" in env.get("RUSTFLAGS", ""):
+            opts += ["-Zbuild-std", "--target", target or host]
+
         if very_verbose:
             print(["Calling", "cargo", "build"] + opts)
             for key in env:

If this turns out to be useful, it might be nice to add .servobuild support for enabling a sanitizer.

Activity

  1. added
    I-safety
    A-build
    on Jul 6, 2020
  2. jdm commented on Jul 7, 2020

    @jdm
    MemberAuthor

    There's a subtlety that took me forever to discover - since the --target flag is required, the binary ends up in target/[target]/servo, so ./mach run ends up running the wrong binary.

  3. added 9 commits that reference this issue on Jul 31, 2020
    43ffdb1
    c8363cf
    4f9fec0
    339a08c
    d215014
    6b5f1d8
    ede352b
    9d0947f
    1e7bf6c
  4. ede1998 commented on Sep 2, 2024

    @ede1998
    Contributor

    @jdm Just stumbled over this issue. Maybe this can be resolved with #31429? Or would you also be interested to have other sanitizers easily available?

  5. jdm commented on Sep 2, 2024

    @jdm
    MemberAuthor

    It would be interesting to see if UBsan works in servo, but we can track that in another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-buildA-machI-safety

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions