Skip to content

[compiler-rt] Remove leftovers of FreeBSD md5/sha2 interceptors #153351

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

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

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Aug 13, 2025

This code was added in 18a7ebd, but was not properly reverted in d0b9c2c.

Removing this code makes it possible to cross-compile TSan for FreeBSD with zig cc which does not provide libcrypt when cross-compiling.

I also removed a term.h include (ncurses) which appeared to be unnecessary and likewise prevented cross-compilation with zig cc from working.

This code was added in 18a7ebd, but was not
properly reverted in d0b9c2c.

Removing this code makes it possible to cross-compile TSan for FreeBSD with
zig cc which does not provide libcrypt when cross-compiling.

I also removed a term.h include (ncurses) which appeared to be unnecessary and
likewise prevented cross-compilation with zig cc from working.
@llvmbot
Copy link
Member

llvmbot commented Aug 13, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Alex Rønne Petersen (alexrp)

Changes

This code was added in 18a7ebd, but was not properly reverted in d0b9c2c.

Removing this code makes it possible to cross-compile TSan for FreeBSD with zig cc which does not provide libcrypt when cross-compiling.

I also removed a term.h include (ncurses) which appeared to be unnecessary and likewise prevented cross-compilation with zig cc from working.


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

2 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp (-22)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h (-16)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
index 4c1e005289230..c4fa1e3c1f6fa 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
@@ -71,14 +71,8 @@
 #include <semaphore.h>
 #include <signal.h>
 #include <stddef.h>
-#include <md5.h>
-#include <sha224.h>
-#include <sha256.h>
-#include <sha384.h>
-#include <sha512.h>
 #include <stdio.h>
 #include <stringlist.h>
-#include <term.h>
 #include <termios.h>
 #include <time.h>
 #include <ttyent.h>
@@ -370,22 +364,6 @@ const int si_SEGV_MAPERR = SEGV_MAPERR;
 const int si_SEGV_ACCERR = SEGV_ACCERR;
 const int unvis_valid = UNVIS_VALID;
 const int unvis_validpush = UNVIS_VALIDPUSH;
-
-const unsigned MD5_CTX_sz = sizeof(MD5_CTX);
-const unsigned MD5_return_length = MD5_DIGEST_STRING_LENGTH;
-
-#define SHA2_CONST(LEN)                                                      \
-  const unsigned SHA##LEN##_CTX_sz = sizeof(SHA##LEN##_CTX);                 \
-  const unsigned SHA##LEN##_return_length = SHA##LEN##_DIGEST_STRING_LENGTH; \
-  const unsigned SHA##LEN##_block_length = SHA##LEN##_BLOCK_LENGTH;          \
-  const unsigned SHA##LEN##_digest_length = SHA##LEN##_DIGEST_LENGTH
-
-SHA2_CONST(224);
-SHA2_CONST(256);
-SHA2_CONST(384);
-SHA2_CONST(512);
-
-#undef SHA2_CONST
 }  // namespace __sanitizer
 
 using namespace __sanitizer;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
index 382b67ce78ebd..1cbb40e0b2ffc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
@@ -710,22 +710,6 @@ extern unsigned IOCTL_KDSKBMODE;
 extern const int si_SEGV_MAPERR;
 extern const int si_SEGV_ACCERR;
 
-extern const unsigned MD5_CTX_sz;
-extern const unsigned MD5_return_length;
-
-#define SHA2_EXTERN(LEN)                          \
-  extern const unsigned SHA##LEN##_CTX_sz;        \
-  extern const unsigned SHA##LEN##_return_length; \
-  extern const unsigned SHA##LEN##_block_length;  \
-  extern const unsigned SHA##LEN##_digest_length
-
-SHA2_EXTERN(224);
-SHA2_EXTERN(256);
-SHA2_EXTERN(384);
-SHA2_EXTERN(512);
-
-#undef SHA2_EXTERN
-
 struct __sanitizer_cap_rights {
   u64 cr_rights[2];
 };

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
View the diff from clang-format here.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
index c4fa1e3c1..ba12bcc62 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp
@@ -70,19 +70,19 @@
 #include <regex.h>
 #include <semaphore.h>
 #include <signal.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stringlist.h>
-#include <termios.h>
-#include <time.h>
-#include <ttyent.h>
-#include <utime.h>
-#include <utmpx.h>
-#include <vis.h>
-#include <wchar.h>
-#include <wordexp.h>
-
-#undef IOC_DIRMASK
+#  include <stddef.h>
+#  include <stdio.h>
+#  include <stringlist.h>
+#  include <termios.h>
+#  include <time.h>
+#  include <ttyent.h>
+#  include <utime.h>
+#  include <utmpx.h>
+#  include <vis.h>
+#  include <wchar.h>
+#  include <wordexp.h>
+
+#  undef IOC_DIRMASK
 
 // Include these after system headers to avoid name clashes and ambiguities.
 #include "sanitizer_internal_defs.h"

@alexrp
Copy link
Member Author

alexrp commented Aug 13, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

Someone can reformat the whole file if they feel like it, but this limited diff pretty clearly makes things worse.

alexrp added a commit to alexrp/zig that referenced this pull request Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants