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

Fails to build on x86_64-unknown-linux-gnux32 due to size mismatch (32 vs. 64 bits) #3

Open
glaubitz opened this issue Oct 22, 2017 · 3 comments

Comments

@glaubitz
Copy link

Trying to bootstrap rustc for x86_64-unknown-linux-gnux32 fails due to mismatching sizes for self.thread.as_pthread_t():

   Compiling jobserver v0.1.8
   Compiling env_logger v0.4.3
error[E0308]: mismatched types
   --> /home/glaubitz/.cargo/registry/src/garden.eu.org-1ecc6299db9ec823/jobserver-0.1.8/src/lib.rs:628:40
    |
628 |                     libc::pthread_kill(self.thread.as_pthread_t(), libc::SIGUSR1);
    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found u32

error: aborting due to previous error

error: Could not compile `jobserver`.

Caused by:
  process didn't exit successfully: `/home/glaubitz/rust/rust/build/bootstrap/debug/rustc --crate-name jobserver /home/glaubitz/.cargo/registry/src/garden.eu.org-1ecc6299db9ec823/jobserver-0.1.8/src/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C opt-level=2 -C metadata=d0dd8f3422c113bb -C extra-filename=-d0dd8f3422c113bb --out-dir /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnux32/release/deps --target x86_64-unknown-linux-gnux32 -L dependency=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnux32/release/deps -L dependency=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/release/deps --extern libc=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnux32/release/deps/liblibc-0d148f7402aae6cb.rlib --cap-lints allow` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed
thread 'main' panicked at 'command did not execute successfully: "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnux32" "--release" "--features" " jemalloc llvm" "--manifest-path" "/home/glaubitz/rust/rust/src/rustc/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101', src/bootstrap/compile.rs:873:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failed to run: /home/glaubitz/rust/rust/build/bootstrap/debug/bootstrap build
Build completed unsuccessfully in 0:29:29
Makefile:22: recipe for target 'all' failed
make: *** [all] Error 1
@glaubitz
Copy link
Author

I could fix this by casting the expression to u64:

glaubitz@z6:..rust/rust> diff -u /home/glaubitz/.cargo/registry/src/garden.eu.org-1ecc6299db9ec823/jobserver-0.1.8/src/{lib.rs~,lib.rs}
--- /home/glaubitz/.cargo/registry/src/garden.eu.org-1ecc6299db9ec823/jobserver-0.1.8/src/lib.rs~  2017-10-20 21:19:01.000000000 +0200
+++ /home/glaubitz/.cargo/registry/src/garden.eu.org-1ecc6299db9ec823/jobserver-0.1.8/src/lib.rs   2017-10-22 18:38:32.223118424 +0200
@@ -625,7 +625,7 @@
                     // return an error, but on other platforms it may not. In
                     // that sense we don't actually know if this will succeed or
                     // not!
-                    libc::pthread_kill(self.thread.as_pthread_t(), libc::SIGUSR1);
+                    libc::pthread_kill(self.thread.as_pthread_t() as u64, libc::SIGUSR1);
                     match self.rx_done.recv_timeout(dur) {
                         Ok(()) |
                         Err(RecvTimeoutError::Disconnected) => {
glaubitz@z6:..rust/rust>

@alexcrichton
Copy link
Member

Sounds like the libstd definition for pthread_t is wrong.

@glaubitz
Copy link
Author

Yep, that's the problem.

For reference, see this small C test program:

glaubitz@z6:~> cat x32_test.c
#include <stdio.h>
#include <bits/pthreadtypes.h>

int main () {
  
  printf("The size of pthread_t is: %d\n", sizeof(pthread_t));
  printf("The size of unsigned long is: %d\n", sizeof(unsigned long));
  return 0;
}
glaubitz@z6:~> gcc -m64 x32_test.c -o x32_test_64
glaubitz@z6:~> gcc -mx32 x32_test.c -o x32_test_x32
glaubitz@z6:~> ./x32_test_64 
The size of pthread_t is: 8
The size of unsigned long is: 8
glaubitz@z6:~> ./x32_test_x32 
The size of pthread_t is: 4
The size of unsigned long is: 4
glaubitz@z6:~>

So, maybe Rust's assumption is wrong that c_ulong is 64 bits on x32?

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

No branches or pull requests

2 participants