Skip to content
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

[libc++] Add a new job running the CFI sanitizer #124837

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Jan 28, 2025

No description provided.

@ldionne ldionne requested a review from a team as a code owner January 28, 2025 21:07
@llvmbot llvmbot added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. github:workflow labels Jan 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 28, 2025

@llvm/pr-subscribers-github-workflow

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/124837.diff

4 Files Affected:

  • (modified) .github/workflows/libcxx-build-and-test.yaml (+2)
  • (added) libcxx/cmake/caches/Generic-cfisan.cmake (+1)
  • (modified) libcxx/utils/ci/run-buildbot (+5)
  • (modified) libcxx/utils/libcxx/test/params.py (+4)
diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index ee77e83363d37a..4544e82e3043d5 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -155,6 +155,8 @@ jobs:
           machine: libcxx-self-hosted-linux
         - config: 'generic-asan'
           machine: libcxx-self-hosted-linux
+        - config: 'generic-cfisan'
+          machine: libcxx-self-hosted-linux
         - config: 'generic-tsan'
           machine: libcxx-self-hosted-linux
         - config: 'generic-ubsan'
diff --git a/libcxx/cmake/caches/Generic-cfisan.cmake b/libcxx/cmake/caches/Generic-cfisan.cmake
new file mode 100644
index 00000000000000..150bf9845720b4
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-cfisan.cmake
@@ -0,0 +1 @@
+set(LLVM_USE_SANITIZER "CFI" CACHE STRING "")
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index f1ede6474eb9ee..8a2a2fbcc00641 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -370,6 +370,11 @@ generic-ubsan)
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake"
     check-runtimes
 ;;
+generic-cfisan)
+    clean
+    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cfisan.cmake"
+    check-runtimes
+;;
 #
 # Various build configurations
 #
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 8fd3872cd8cbb0..947883c9d356e9 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -303,6 +303,7 @@ def getSuitableClangTidy(cfg):
             "",
             "Address",
             "HWAddress",
+            "CFI",
             "Undefined",
             "Memory",
             "MemoryWithOrigins",
@@ -327,6 +328,9 @@ def getSuitableClangTidy(cfg):
                 AddFlag("-fsanitize=hwaddress") if sanitizer == "HWAddress" else None,
                 AddFeature("hwasan")            if sanitizer == "HWAddress" else None,
 
+                AddFlag("-fsanitize=cfi") if sanitizer == "CFI" else None,
+                AddFeature("cfi")         if sanitizer == "CFI" else None,
+
                 AddFlag("-fsanitize=memory")               if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
                 AddFeature("msan")                         if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
                 AddFlag("-fsanitize-memory-track-origins") if sanitizer == "MemoryWithOrigins" else None,

@philnik777
Copy link
Contributor

The CFI documentation says that you need LTO, so we probably have to explicitly enable that as well and use lld (since bfd doesn't support LTO)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github:workflow libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants