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

jemalloc-sys: hardening strerror_r function detection #117

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions jemalloc-ctl/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ macro_rules! r {

#[cfg(test)]
#[test]
#[cfg(not(target_arch = "mips64el"))]
#[allow(unused)]
fn [<$id _read_test>]() {
match stringify!($id) {
Expand Down Expand Up @@ -112,7 +111,6 @@ macro_rules! w {

#[cfg(test)]
#[test]
#[cfg(not(target_arch = "mips64el"))]
fn [<$id _write_test>]() {
match stringify!($id) {
"background_thread" |
Expand Down Expand Up @@ -161,7 +159,6 @@ macro_rules! u {

#[cfg(test)]
#[test]
#[cfg(not(target_arch = "mips64el"))]
#[allow(unused)]
fn [<$id _update_test>]() {
match stringify!($id) {
Expand Down
1 change: 0 additions & 1 deletion jemalloc-ctl/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ union MaybeUninit<T: Copy> {
mod tests {
use super::*;
#[test]
#[cfg(not(target_arch = "mips64el"))] // FIXME: SIGFPE
fn test_ptr2str() {
unsafe {
//{ // This is undefined behavior:
Expand Down
15 changes: 13 additions & 2 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
.join(" ");
info!("CC={:?}", compiler.path());
info!("CFLAGS={:?}", cflags);

assert!(out_dir.exists(), "OUT_DIR does not exist");
let jemalloc_repo_dir = PathBuf::from("jemalloc");
Expand Down Expand Up @@ -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")
Expand Down
37 changes: 37 additions & 0 deletions jemalloc-sys/configure/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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}"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-sys/jemalloc
Submodule jemalloc updated 1 files
+29 −4 configure.ac