From 8c926d5b367e0cfb37aec9a9ac09f7c92671fbda Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 6 Feb 2025 11:49:49 +0800 Subject: [PATCH 1/2] Revert "don't pass CFLAGS and fix _FORTIFY_SOURCE errors (#116)" This reverts commit fa4486d23f7402f3999b8c857333c60090001314. Signed-off-by: Jay Lee --- jemalloc-sys/build.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index 3de7437c8..b91d3e3d6 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -145,9 +145,17 @@ fn main() { println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]); return; } - - let compiler = cc::Build::new().get_compiler(); + // Disable -Wextra warnings - jemalloc doesn't compile free of warnings with + // it enabled: https://github.com/jemalloc/jemalloc/issues/1196 + let compiler = cc::Build::new().extra_warnings(false).get_compiler(); + let cflags = compiler + .args() + .iter() + .map(|s| s.to_str().unwrap()) + .collect::>() + .join(" "); info!("CC={:?}", compiler.path()); + info!("CFLAGS={:?}", cflags); assert!(out_dir.exists(), "OUT_DIR does not exist"); let jemalloc_repo_dir = PathBuf::from("jemalloc"); @@ -182,6 +190,9 @@ fn main() { ) .current_dir(&build_dir) .env("CC", compiler.path()) + .env("CFLAGS", cflags.clone()) + .env("LDFLAGS", cflags.clone()) + .env("CPPFLAGS", cflags) .arg(format!("--with-version={je_version}")) .arg("--disable-cxx") .arg("--enable-doc=no") From 143c25363079fca9d6f6f69255e039a9e45f8346 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 6 Feb 2025 12:52:47 +0800 Subject: [PATCH 2/2] jemalloc-sys: hardening strerror_r function detection test on strerror_r can fail due to reasons other than strerror_r itself, so add an additional test to determine the failure is expected. Also remove stale arch condition. Close #108. Signed-off-by: Jay Lee --- jemalloc-ctl/src/macros.rs | 3 --- jemalloc-ctl/src/raw.rs | 1 - jemalloc-sys/configure/configure | 37 ++++++++++++++++++++++++++++++++ jemalloc-sys/jemalloc | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/jemalloc-ctl/src/macros.rs b/jemalloc-ctl/src/macros.rs index ee4bd5ff0..23f48e7f5 100644 --- a/jemalloc-ctl/src/macros.rs +++ b/jemalloc-ctl/src/macros.rs @@ -63,7 +63,6 @@ macro_rules! r { #[cfg(test)] #[test] - #[cfg(not(target_arch = "mips64el"))] #[allow(unused)] fn [<$id _read_test>]() { match stringify!($id) { @@ -112,7 +111,6 @@ macro_rules! w { #[cfg(test)] #[test] - #[cfg(not(target_arch = "mips64el"))] fn [<$id _write_test>]() { match stringify!($id) { "background_thread" | @@ -161,7 +159,6 @@ macro_rules! u { #[cfg(test)] #[test] - #[cfg(not(target_arch = "mips64el"))] #[allow(unused)] fn [<$id _update_test>]() { match stringify!($id) { diff --git a/jemalloc-ctl/src/raw.rs b/jemalloc-ctl/src/raw.rs index 8fd60351f..e34d13e3d 100644 --- a/jemalloc-ctl/src/raw.rs +++ b/jemalloc-ctl/src/raw.rs @@ -385,7 +385,6 @@ union MaybeUninit { mod tests { use super::*; #[test] - #[cfg(not(target_arch = "mips64el"))] // FIXME: SIGFPE fn test_ptr2str() { unsafe { //{ // This is undefined behavior: diff --git a/jemalloc-sys/configure/configure b/jemalloc-sys/configure/configure index 7c4e6e266..3c9f8a04b 100755 --- a/jemalloc-sys/configure/configure +++ b/jemalloc-sys/configure/configure @@ -14143,6 +14143,41 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_strerror_r_returns_char_with_gnu_source" >&5 $as_echo "$je_cv_strerror_r_returns_char_with_gnu_source" >&6; } +if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xno" ; then + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r header only is compilable" >&5 +$as_echo_n "checking whether strerror_r header only is compilable... " >&6; } +if ${je_cv_strerror_r_header_pass+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + je_cv_strerror_r_header_pass=yes +else + je_cv_strerror_r_header_pass=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $je_cv_strerror_r_header_pass" >&5 +$as_echo "$je_cv_strerror_r_header_pass" >&6; } + +fi CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" if test "x${CONFIGURE_CFLAGS}" = "x" -o "x${SPECIFIED_CFLAGS}" = "x" ; then CFLAGS="${CONFIGURE_CFLAGS}${SPECIFIED_CFLAGS}" @@ -14155,6 +14190,8 @@ if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xyes" ; then $as_echo "#define JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE " >>confdefs.h +elif test "x${je_cv_strerror_r_header_pass}" = "xno" ; then + as_fn_error $? "cannot determine return type of strerror_r" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 diff --git a/jemalloc-sys/jemalloc b/jemalloc-sys/jemalloc index e13ca993e..09ad115bc 160000 --- a/jemalloc-sys/jemalloc +++ b/jemalloc-sys/jemalloc @@ -1 +1 @@ -Subproject commit e13ca993e8ccb9ba9847cc330696e02839f328f7 +Subproject commit 09ad115bc02db60cc9d9338cf0067074d3135fb4