Skip to content

Add SO_REUSEPORT for Android #70

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

Merged
merged 1 commit into from
Jan 11, 2016

Conversation

SimonSapin
Copy link
Contributor

The net2 crate currently fails to cross-compile to Android with error: unresolved name libc::SO_REUSEPORT``

According to http://stackoverflow.com/a/14388707/1162888, Android is essentially the same as Linux for the purpose of socket features support, and the Linux kernel has supported SO_REUSEPORT since version 3.9.

According to http://android.stackexchange.com/a/51656, Android has had more recent kernels than that since version 4.4 Kit Kat.

(This blocks servo/servo#8446.)

@alexcrichton
Copy link
Member

The CI here is failing which'll prevent this from landing, and I'd prefer o have constants like this verified on Android. If it's actually present then are there more recent Android compilers and/or headers which have the constants?

@SimonSapin
Copy link
Contributor Author

I’m not sure. FWIW, grep on my system finds SO_REUSEPORT under /opt/android-ndk/platforms/android-21, but not under android-19/ or earlier versions.

If in doubt, would you rather have the reuse_port methods on net2 not be there on android? I’d like to make net2 compile somehow.

@alexcrichton
Copy link
Member

Ok, I've updated our docker images to use API level 21 instead of 18 (I at least don't know of a reason to use an older one right now) and I'm in the process of uploading the new image tagged as 2015-11-22, and if you update this line to the new tag it should pick it up automatically and enable verification.

Note that it takes awhile to upload, so it may be ~15min before the image is available (travis may take awhile to get around to it though)

SimonSapin added a commit to SimonSapin/libc that referenced this pull request Nov 22, 2015
@SimonSapin
Copy link
Contributor Author

I’ve pushed a new commit but https://travis-ci.org/rust-lang-nursery/libc/requests doesn’t show a request for a new build.

@alexcrichton
Copy link
Member

Hm it looks like this PR doesn't yet include that change? (but seems referenced?)

SimonSapin added a commit to SimonSapin/libc that referenced this pull request Nov 23, 2015
@SimonSapin
Copy link
Contributor Author

I pushed to the wrong branch :)

SimonSapin added a commit to SimonSapin/libc that referenced this pull request Nov 23, 2015
@SimonSapin
Copy link
Contributor Author

https://travis-ci.org/rust-lang-nursery/libc/builds/92660417 failed with

Unable to find image 'alexcrichton/rust-slave-android:2015-11-22' locally
2015-11-22: Pulling from alexcrichton/rust-slave-android

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

Pushing the same commit again to trigger another build.

@SimonSapin
Copy link
Contributor Author

Same again. Any suggestion @alexcrichton ? 2015-11-22 does show up in https://hub.docker.com/r/alexcrichton/rust-slave-android/tags/ Could the 10 min limit be hit while Travis is downloading a 2 GB image?

@alexcrichton
Copy link
Member

I hit restart on this build but it may be time to use travis_wait when running docker

@alexcrichton
Copy link
Member

Looks like there was some trouble finding travis_wait?

@SimonSapin
Copy link
Contributor Author

Yeah, it looks like what I did is not correct usage, but I don’t know what is. Is travis_wait a magic string rather than an executable?

@SimonSapin SimonSapin force-pushed the SO_REUSEPORT-android branch 2 times, most recently from 2cd24f0 to 779ffb4 Compare November 24, 2015 12:42
@SimonSapin
Copy link
Contributor Author

After trying a few random places to insert travis_wait:

The command "if [[ $TRAVIS_RUST_VERSION = nightly* ]]; then travis_wait sh ci/run-travis.sh; else cargo build; fi" exited with 1.
Log:

[…]

exec sh ci/run.sh arm-linux-androideabi
cannot enable tty mode on non tty input
/home/travis/build.sh: line 112:  5330 Terminated              travis_jigger $! $timeout $cmd

SimonSapin added a commit to SimonSapin/net2-rs that referenced this pull request Nov 24, 2015
The only methods it define require libc::SO_REUSEPORT,
which current versions on the libc crate does not provide for Android targets.

This is a temporary work around to make this crate build at all on Android.
It should be reverted
when rust-lang/libc#70 lands.
SimonSapin added a commit to SimonSapin/net2-rs that referenced this pull request Nov 24, 2015
The only methods it define require libc::SO_REUSEPORT,
which current versions on the libc crate does not provide for Android targets.

This is a temporary work around to make this crate build at all on Android.
It should be reverted
when rust-lang/libc#70 lands.

This not a breaking change since the crate did not build at all before.
@alexcrichton
Copy link
Member

I believe this is just because docker is being run with -t which says "Allocate a pseudo-TTY" which apparently travis_wait doesn't like. I'm gonna see if dropping that works -- #74.

@SimonSapin SimonSapin force-pushed the SO_REUSEPORT-android branch 2 times, most recently from 0f07feb to 0240ec7 Compare November 25, 2015 09:21
@SimonSapin
Copy link
Contributor Author

Trying a variation of #74:

before_script:
  - if [ "$TARGET" = "arm-linux-androideabi" ]; then
      travis_wait docker pull $(cat android-docker-image);
    fi
Timeout (20 minutes) reached. Terminating "docker pull alexcrichton/rust-slave-android:2015-11-22"

SimonSapin added a commit to SimonSapin/libc that referenced this pull request Nov 25, 2015
@SimonSapin
Copy link
Contributor Author

So I replaced travis_wait with strace -f and the raw log ends with:

The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).
The job has been terminated

… but the job ran for 47 min 41 sec already, so even with another trick to have less output it’s likely to hit the 50 min timeout.

@SimonSapin
Copy link
Contributor Author

The raw log also contains "Layer already being pulled by another client. Waiting."

@metajack
Copy link

cc @edunham

I think perhaps it's time to bring in our ops team :)

@alexcrichton
Copy link
Member

Now that I merged #88, could this be rebased? I think it should "Just Work" to add the constant now. (sorry for the runaround!)

@SimonSapin
Copy link
Contributor Author

Rebased.

The `net2` crate currently fails to cross-compile to Android with
``error: unresolved name `libc::SO_REUSEPORT` ``

According to http://stackoverflow.com/a/14388707/1162888,
Android is essentially the same as Linux for the purpose of
socket features support, and the Linux kernel has supported
`SO_REUSEPORT` since version 3.9.

According to http://android.stackexchange.com/a/51656,
Android has had more recent kernels than that since version 4.4 Kit Kat.
@SimonSapin
Copy link
Contributor Author

Reverted version number bump, as it made tests fail to find libc at that version (presumably from crates.io?)

Travis failure on MIPS doesn’t looks related to this change?

error: linking with `mips-linux-gnu-gcc` failed: exit code: 1

note: "mips-linux-gnu-gcc" "-Wl,--as-needed" "-L" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib" "/home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/libc_test.0.o" "-o" "/home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/libc_test" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug" "-L" "/home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/deps" "-L" "/home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/build/libc-test-a6cd229ea2045071/out" "-L" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "all" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "/home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/deps/liblibc-f8fceda7be8f9ea9.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/libstd-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/libcollections-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/librustc_unicode-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/librand-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/liballoc-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/liballoc_jemalloc-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/liblibc-17a8ccbd.rlib" "/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/libcore-17a8ccbd.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "compiler-rt"

note: /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: /home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/libc_test uses hard float, /home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/libstd-17a8ccbd.rlib(fileline.o) uses soft float

/usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: /home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/libc_test uses hard float, /home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/libstd-17a8ccbd.rlib(posix.o) uses soft float

...

/usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: /home/travis/build/rust-lang-nursery/libc/libc-test/target/mips-unknown-linux-gnu/debug/libc_test uses hard float, /home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/libcompiler-rt.a(mulodi4.o) uses soft float

/usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Dwarf Error: found dwarf version '4', this reader only handles version 2 and 3 information.

/usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Dwarf Error: found dwarf version '0', this reader only handles version 2 and 3 information.

/home/travis/rust/lib/rustlib/mips-unknown-linux-gnu/lib/liballoc_jemalloc-17a8ccbd.rlib(jemalloc.pic.o): In function `malloc_conf_init':

/buildslave/rust-buildbot/slave/nightly-dist-rustc-cross-linux/build/src/jemalloc/src/jemalloc.c:(.text.malloc_conf_init+0x94): undefined reference to `secure_getenv'

/usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Dwarf Error: found dwarf version '0', this reader only handles version 2 and 3 information.

/usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Dwarf Error: found dwarf version '3072', this reader only handles version 2 and 3 information.

/buildslave/rust-buildbot/slave/nightly-dist-rustc-cross-linux/build/src/jemalloc/src/jemalloc.c:(.text.malloc_conf_init+0x98): undefined reference to `secure_getenv'

collect2: ld returned 1 exit status

error: aborting due to previous error

Could not compile `libc-test`.

@alexcrichton alexcrichton merged commit 52f4f39 into rust-lang:master Jan 11, 2016
danielverkamp pushed a commit to danielverkamp/libc that referenced this pull request Apr 28, 2020
* Docs: Fix typo in module documentation

s/paltform/platform/g

* [x86] Implement sse4.2 string cmp intrinsics

 - Implement
   - _mm_cmpistrm
   - _mm_cmpistri
   - _mm_cmpistrz
   - _mm_cmpistrc
   - _mm_cmpistrs
   - _mm_cmpistro
   - _mm_cmpistra
   - _mm_cmpestrm
   - _mm_cmpestrz
   - _mm_cmpestrc
   - _mm_cmpestrs
   - _mm_cmpestro
   - _mm_cmpestra
 - Add documentation to _mm_cmpestri
 - Add missing constants
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.

3 participants