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

Add mq_getfd_np() on FreeBSD and fix mqd_t on DragonFlyBSD #1308

Merged
merged 2 commits into from Mar 28, 2019

Conversation

tormol
Copy link
Contributor

@tormol tormol commented Mar 27, 2019

mq_getfd_np() was added in FreeBSD 11. I'm already using it in my posixmq crate for mio/kqueue integration, and I've tested it both in virtualbox and on Cirrus-CI.

mqd_t in an int on DragonFlyBSD even though it's a pointer on FreeBSD, because DragonflyBSD's implementation is based on NetBSD. The definitions for mq_attr are already separate and correct.
Does fixing this count as a breaking change? I think the current definition will work in most cases, because IIRC the calling convention means that mqd_t is always passed via registers, the upper 32 bits might just contain garbage.
I've not tested this change on DragonFlyBSD.

I want to add mq symbols for solarish, but is the CDDL license compatible with Apache-2.0 and MIT?

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 28, 2019

@asomers
Copy link
Contributor

asomers commented Mar 28, 2019

The change looks correct to me. I don't think that it should be considered a breaking change when the old definitions were simply wrong. There is precedent within libc for fixing incorrect definitions. Oh, and posixmq looks cool!

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 28, 2019

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 28, 2019

📌 Commit 652b832 has been approved by gnzlbg

bors added a commit that referenced this pull request Mar 28, 2019
Add mq_getfd_np() on FreeBSD and fix mqd_t on DragonFlyBSD

[`mq_getfd_np()` was added in FreeBSD 11](https://svnweb.freebsd.org/base/stable/11/include/mqueue.h?revision=306905&view=markup). I'm already using it in my [posixmq crate](https://github.com/tormol/posixmq) for mio/kqueue integration, and I've tested it both in virtualbox and on Cirrus-CI.

[`mqd_t` in an `int` on DragonFlyBSD](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/e7ab884bd49753f8884eb597d10d6569a08fa0df/sys/sys/types.h#L139) even though it's a pointer on FreeBSD, because [DragonflyBSD's implementation is based on NetBSD](DragonFlyBSD/DragonFlyBSD@f2df0f7). The definitions for `mq_attr` are already separate and correct.
Does fixing this count as a breaking change? I think the current definition will work in most cases, because IIRC the calling convention means that `mqd_t` is always passed via registers, the upper 32 bits might just contain garbage.
I've *not* tested this change on DragonFlyBSD.

I want to add mq symbols for solarish, but is the CDDL license compatible with Apache-2.0 and MIT?
@bors
Copy link
Contributor

bors commented Mar 28, 2019

⌛ Testing commit 652b832 with merge f682ca6...

@strangelittlemonkey
Copy link

strangelittlemonkey commented Mar 28, 2019 via email

@bors
Copy link
Contributor

bors commented Mar 28, 2019

@strangelittlemonkey: 🔑 Insufficient privileges: Not in reviewers

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 28, 2019

@strangelittlemonkey that would be great!

@bors
Copy link
Contributor

bors commented Mar 28, 2019

☀️ Test successful - checks-cirrus, checks-travis, status-appveyor
Approved by: gnzlbg
Pushing f682ca6 to master...

@bors bors merged commit 652b832 into rust-lang:master Mar 28, 2019
@strangelittlemonkey
Copy link

I got around to compiling and things are broken on DragonFly again. The breaking commit seems to have been 7ac0fe5. Looks like it needs some fixes to casting again.

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 30, 2019

@strangelittlemonkey by broken you mean the libc-test right? not the build, right? That commit seems unrelated to this one :)

@strangelittlemonkey
Copy link

zach@dev03 ~/libc> cargo build
Compiling libc v0.2.49 (/home/zach/libc)
error[E0308]: mismatched types
--> src/unix/bsd/freebsdlike/dragonfly/mod.rs:807:9
|
806 | pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
| -------- expected u32 because of return type
807 | _CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found usize

error[E0308]: mismatched types
--> src/unix/bsd/freebsdlike/dragonfly/mod.rs:813:48
|
813 | let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len)
| ^^^^^^^^^^^^^^^^ expected usize, found u32

error[E0308]: mismatched types
--> src/unix/bsd/freebsdlike/dragonfly/mod.rs:818:42
|
818 | (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len)) as *mut ::cmsghdr
| ^^^^^^^^^^^^^^^^ expected usize, found u32

error[E0308]: mismatched types
--> src/unix/bsd/freebsdlike/dragonfly/mod.rs:825:9
|
824 | pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
| -------- expected u32 because of return type
825 | / CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) +
826 | | CMSG_ALIGN(length as usize)
| |
______________________________________^ expected u32, found usize

error: aborting due to 4 previous errors

For more information about this error, try rustc --explain E0308.
error: Could not compile libc.

To learn more, run the command again with --verbose.

Whether or not libc-test passes, if the build fails I can't use it as a lib in a project :)

@tormol
Copy link
Contributor Author

tormol commented Mar 30, 2019 via email

@strangelittlemonkey
Copy link

strangelittlemonkey commented Mar 30, 2019 via email

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 30, 2019

@strangelittlemonkey from your build output (emphasis mine):

zach@dev03 ~/libc> cargo build
Compiling libc v0.2.49 (/home/zach/libc)

If it were master branch, it would have said v0.2.51 instead. Maybe you pulled the master branch from an old fork?

@strangelittlemonkey
Copy link

strangelittlemonkey commented Mar 30, 2019 via email

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 30, 2019

I think you might be picking up a too old ctest as well..

@strangelittlemonkey
Copy link

Ok, to be sure I cloned a clean copy and ran it.

zach@dev03 ~/l/libc-test> cargo test
Downloading crates ...
Downloaded ctest v0.2.13
Compiling proc-macro2 v0.4.27
Compiling unicode-xid v0.1.0
Compiling syn v0.15.29
Compiling semver-parser v0.7.0
Compiling serde v1.0.89
Compiling libc v0.2.51
Compiling num-traits v0.2.6
Compiling ryu v0.2.7
Compiling cfg-if v0.1.7
Compiling term v0.4.6
Compiling itoa v0.4.3
Compiling bitflags v0.9.1
Compiling cc v1.0.32
Compiling libc v0.2.51 (/home/zach/libc-test-test-test)
Compiling semver v0.9.0
Compiling log v0.4.6
Compiling rustc_version v0.2.3
Compiling log v0.3.9
Compiling rand v0.4.6
Compiling quote v0.6.11
Compiling extprim v1.6.0
Compiling serde_derive v1.0.89
Compiling syntex_pos v0.59.1
Compiling serde_json v1.0.39
Compiling syntex_errors v0.59.1
Compiling syntex_syntax v0.59.1
Compiling ctest v0.2.13
Compiling libc-test v0.1.0 (/home/zach/libc-test-test-test/libc-test)
error: failed to run custom build command for libc-test v0.1.0 (/home/zach/libc-test-test-test/libc-test)
process didn't exit successfully: /home/zach/libc-test-test-test/target/debug/build/libc-test-4533869729459918/build-script-build (exit code: 101)
--- stdout
TARGET = Some("x86_64-unknown-dragonfly")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-dragonfly")
CC_x86_64-unknown-dragonfly = None
CC_x86_64_unknown_dragonfly = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-dragonfly = None
CFLAGS_x86_64_unknown_dragonfly = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-o" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/src/cmsg.o" "-c" "src/cmsg.c"
exit code: 0
AR_x86_64-unknown-dragonfly = None
AR_x86_64_unknown_dragonfly = None
HOST_AR = None
AR = None
running: "ar" "crs" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/libcmsg.a" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/src/cmsg.o"
exit code: 0
cargo:rustc-link-lib=static=cmsg
cargo:rustc-link-search=native=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out

cargo:rerun-if-changed=../src/lib.rs
cargo:rerun-if-changed=../src/macros.rs
cargo:rerun-if-changed=../src/unix/mod.rs
cargo:rerun-if-changed=../src/unix/bsd/mod.rs
cargo:rerun-if-changed=../src/unix/bsd/freebsdlike/mod.rs
cargo:rerun-if-changed=../src/unix/bsd/freebsdlike/dragonfly/mod.rs
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-dragonfly")
CC_x86_64-unknown-dragonfly = None
CC_x86_64_unknown_dragonfly = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-dragonfly = None
CFLAGS_x86_64_unknown_dragonfly = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter" "-Wno-type-limits" "-Wno-address-of-packed-member" "-Wno-deprecated-declarations" "-Wno-deprecated-declarations" "-o" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.o" "-c" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c"
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c:9756:64: error: 'IP_SENDSRCADDR' undeclared here (not in a function); did you mean 'IP_RECVDSTADDR'?
cargo:warning= static const int __test_const_IP_SENDSRCADDR_val = IP_SENDSRCADDR;
cargo:warning= ^~~~~~~~~~~~~~
cargo:warning= IP_RECVDSTADDR
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c:11646:63: error: 'BPF_ALIGNMENT' undeclared here (not in a function); did you mean 'RB_AUGMENT'?
cargo:warning= static const int __test_const_BPF_ALIGNMENT_val = BPF_ALIGNMENT;
cargo:warning= ^~~~~~~~~~~~~
cargo:warning= RB_AUGMENT
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c: In function '__test_fn_lio_listio':
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c:11899:24: error: returning 'int ()(int, struct aiocb * const restrict restrict, int, struct sigevent * restrict)' from a function with incompatible return type 'int ()(int, struct aiocb * const, int, struct sigevent )' [-Werror=incompatible-pointer-types]
cargo:warning= return lio_listio;
cargo:warning= ^~~~~~~~~~
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c: In function '__test_field_type_statfs_f_mntonname':
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c:14278:28: error: returning 'char (
)[80]' from a function with incompatible return type 'char ()[90]' [-Werror=incompatible-pointer-types]
cargo:warning= return &b->f_mntonname;
cargo:warning= ^~~~~~~~~~~~~~~
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c: In function '__test_field_type_statfs_f_mntfromname':
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c:14320:28: error: returning 'char (
)[80]' from a function with incompatible return type 'char (*)[90]' [-Werror=incompatible-pointer-types]
cargo:warning= return &b->f_mntfromname;
cargo:warning= ^~~~~~~~~~~~~~~~~
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c: At top level:
cargo:warning=/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c:16754:69: error: 'SF_CACHE' undeclared here (not in a function); did you mean 'UF_CACHE'?
cargo:warning= static const unsigned long __test_const_SF_CACHE_val = SF_CACHE;
cargo:warning= ^~~~~~~~
cargo:warning= UF_CACHE
cargo:warning=cc1: error: unrecognized command line option '-Wno-address-of-packed-member' [-Werror]
cargo:warning=cc1: all warnings being treated as errors
exit code: 1

--- stderr
rust version: 1.31.1
thread 'main' panicked at '

Internal error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Wall" "-Wextra" "-Werror" "-Wno-unused-parameter" "-Wno-type-limits" "-Wno-address-of-packed-member" "-Wno-deprecated-declarations" "-Wno-deprecated-declarations" "-o" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.o" "-c" "/home/zach/libc-test-test-test/target/debug/build/libc-test-26322326a0381a10/out/main.c" with args "cc" did not execute successfully (status code exit code: 1).

', /home/zach/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.32/src/lib.rs:2367:5
note: Run with RUST_BACKTRACE=1 for a backtrace.

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 31, 2019

So it appears that, at least on your dragonflybsd version:

  • IP_SENDSRCADDR does not exist (or the header is not included by libc-test)
  • BPF_ALIGNMENT does not exist (or the header is not included by libc-test)
  • SF_CACHE does not exist (or the header is not included by libc-test)
  • the signature of lio_listio is incorrect - the last argument should be a struct sigevent *, but is just a struct sigevent
  • the length of statfs field `mntonname' is incorrect (90 vs 80 char)

which DragonflyBSD version are you using @strangelittlemonkey ? @tormol which DragonflyBSD version did you test?

@tormol
Copy link
Contributor Author

tormol commented Mar 31, 2019

I wasn't testing libc other than using it as a dependency.
I've now tried to test libc-test, and get the same errors as @strangelittlemonkey.
I'm using DragonFlyBSD v5.4.1-RELEASE #2, X86_64_GENERIC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants