Auto merge of #937 - bdrewery:freebsd-ino64-compat, r=alexcrichton

Use pre-ino64 FreeBSD symbols to resolve binary compatibility.

This follows the same method as other platforms like OSX and NetBSD.

This will fix rustup and building from git (once libc is updated for bootstrap)
on FreeBSD12 post-ino64 in f713b08c02.
It also avoids having to hotpatch the stage0 compiler, and HOME/.cargo
libc files on FreeBSD12 to build rust.

The only real pitfall is that this will prevent interaction with inodes that
have an ino_t above the 32-bit limit due to truncation.  On the other hand
Rust won't work at all on 12 without doing this currently.  In general
it should not be a problem for users and if they need 64-bit ino_t they
can use a patched libc, rather than the current state of affairs in
requiring a patched libc to use Rust on 12.

A better, or complementary, approach would be something like proposed in
https://github.com/rust-lang/rfcs/pull/2048 to allow targetting a specific
version of FreeBSD. This would allow Rust to default to this compatibility
mode by targetting FreeBSD10 and still allow targetting FreeBSD12 for 64-bit
ino_t.

The symbol versions used were taken from the old version in
f713b08c02 (diff-61a32fcfb7ecd4517665fed591813c57)
and
f713b08c02 (diff-7f67ccf8b5f44ff2f54eaab0207abb8d).

The scope of functions versioned here differs from other platforms as
not all structs were modified that were on others, such as DIR for
`opendir`, `telldir`, etc.  Only functions using dirent, stat, glob_t,
and dev_t need the changes.

Fixes https://github.com/rust-lang/rust/issues/42681
This commit is contained in:
bors 2018-03-02 01:19:11 +00:00
commit 68d4848fe6
3 changed files with 10 additions and 0 deletions

View file

@ -1151,6 +1151,7 @@ extern {
pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
#[cfg_attr(target_os = "freebsd", link_name = "mknodat@FBSD_1.1")]
pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
mode: ::mode_t, dev: dev_t) -> ::c_int;
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,

View file

@ -400,12 +400,14 @@ extern {
#[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
#[cfg_attr(target_os = "freebsd", link_name = "glob@FBSD_1.0")]
pub fn glob(pattern: *const ::c_char,
flags: ::c_int,
errfunc: Option<extern fn(epath: *const ::c_char,
errno: ::c_int) -> ::c_int>,
pglob: *mut ::glob_t) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
#[cfg_attr(target_os = "freebsd", link_name = "globfree@FBSD_1.0")]
pub fn globfree(pglob: *mut ::glob_t);
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)

View file

@ -384,12 +384,14 @@ extern {
#[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
#[cfg_attr(target_os = "freebsd", link_name = "fstat@FBSD_1.0")]
pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
#[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
#[cfg_attr(target_os = "freebsd", link_name = "stat@FBSD_1.0")]
pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
pub fn pclose(stream: *mut ::FILE) -> ::c_int;
@ -416,10 +418,12 @@ extern {
pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
#[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
#[cfg_attr(target_os = "freebsd", link_name = "readdir@FBSD_1.0")]
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_readdir_r")]
#[cfg_attr(target_os = "freebsd", link_name = "readdir_r@FBSD_1.0")]
pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
result: *mut *mut ::dirent) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
@ -442,6 +446,7 @@ extern {
owner: ::uid_t, group: ::gid_t,
flags: ::c_int) -> ::c_int;
#[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
#[cfg_attr(target_os = "freebsd", link_name = "fstatat@FBSD_1.1")]
pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char,
buf: *mut stat, flags: ::c_int) -> ::c_int;
pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char,
@ -595,6 +600,7 @@ extern {
#[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
#[cfg_attr(target_os = "freebsd", link_name = "lstat@FBSD_1.0")]
pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
@ -779,6 +785,7 @@ extern {
pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
#[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")]
pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
dev: ::dev_t) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;