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

Compilation error on 32 bit machine #3643

shodow opened this issue Aug 30, 2017 · 5 comments

Compilation error on 32 bit machine #3643

shodow opened this issue Aug 30, 2017 · 5 comments


Copy link

@shodow shodow commented Aug 30, 2017

When i run ./ in Ubuntu 16.04 32bit i got this error("./src/tools/singlejar/mapped_file.h:40:2: error: #error This code for 64 bit Unix"),how can i do?
i follow #3382 to modify src/main/java/com/google/devtools/build/lib/util/ (line 23-29)and
tools/cpp/lib_cc_configure.bzl (line 106)like this

# Use uname to figure out whether we are on x86_32 or x86_64
  result = repository_ctx.execute(["uname", "-m"])
  if result.stdout.strip() in ["power", "ppc64le", "ppc", "ppc64"]:
    return "ppc"
  if result.stdout.strip() in ["arm", "armv7l", "aarch64"]:
    return "arm"
  if result.stdout.strip() in ["i386", "i486", "i586", "i686", "i786", "x86"]:
    return "piii"
public enum CPU {
  X86_32("piii", ImmutableSet.of("i386", "i486", "i586", "i686", "i786", "x86")),
  X86_64("x86_64", ImmutableSet.of("amd64", "x86_64", "x64")),
  PPC("ppc", ImmutableSet.of("ppc", "ppc64", "ppc64le")),
  ARM("arm", ImmutableSet.of("aarch64", "arm", "armv7l")),
  S390X("s390x", ImmutableSet.of("s390x", "s390")),
  UNKNOWN("unknown", ImmutableSet.<String>of());

but it's not work...

Bazel version : 0.5.4
my machine information is :

$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK Server VM (build 25.131-b11, mixed mode)
$ uname -a
Linux ubuntu 4.10.0-32-generic #36~16.04.1-Ubuntu SMP Wed Aug 9 09:18:53 UTC 2017 i686 i686 i686 GNU/Linux
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

This comment has been minimized.

Copy link

@aehlig aehlig commented Aug 30, 2017

If you know you're on a 32-bit machine, generally the best approach is to completely ignore the C-implementation of singlejar: (the type fix also in that patch is upstream, but didn't make it into 0.5.4).


This comment has been minimized.

Copy link

@shodow shodow commented Aug 31, 2017

I seem to have solved this problem,
I just delete this line (./src/tools/singlejar/mapped_file.h:40: error: #error This code for 64 bit Unix)
i don't konw why and whether it is affected,but at present it's no error.


This comment has been minimized.

Copy link

@shodow shodow commented Aug 31, 2017

@aehlig thank you very much ,I'll have a try :)


This comment has been minimized.

Copy link

@vladmos vladmos commented Sep 1, 2017

I'm closing the issue as you've solved the problem and the proper fix has been submitted already, feel free to reopen if you have any questions.

@vladmos vladmos closed this Sep 1, 2017

This comment has been minimized.

Copy link

@likan999 likan999 commented Oct 9, 2017

The fix of replacing "//src/tools/singlejar:singlejar" with "//src/java_tools/singlejar:SingleJar_deploy.jar" doesn't work. It makes the ./ succeeds, but the resulting bazel can't be used to build scripts/packages:with-jdk/

[xyz@xyz-mac-fc-x86 bazel]$ output/bazel build scripts/packages:with-jdk/                                                                               
Extracting Bazel installation...         
ERROR: /home/xyz/.cache/bazel/_bazel_xyz/97cdd804d556cb3de47debcf86f945f6/external/bazel_tools/tools/jdk/BUILD:187:17: in singlejar attribute of java_toolchain rule @bazel_tools//tools/jdk:toolchain: '@bazel_tools//tools/jdk:singlejar' must produce a single file.                                                                 
ERROR: Analysis of target '//scripts/packages:with-jdk/' failed; build aborted.                                                                             
INFO: Elapsed time: 2.894s    

On the other hand, if I try another approach of deleting the line #error This code for 64 bit Unix, ./ succeeds, and output/bazel build //scripts/packages:with-jdk/ also succeeds, but when executing the result, it fails. The root cause is the generated java toolchain is 64-bits, therefore can't run on 32-bit system:

[xyz@xyz-mac-fc-x86 bazel]$ bazel-bin/scripts/packages/with-jdk/ --user
Bazel installer

Bazel is bundled with software licensed under the GPLv2 with Classpath exception.
You can find the sources next to the installer on our release page:

# Binary package at HEAD (@)
   - [Commit](
Uncompressing......Java version not detected while at least 1.8 is needed.
Please set JAVA_HOME.
[xyz@xyz-mac-fc-x86 bazel]$ /home/xyz/.cache/bazel/_bazel_xyz/install/6358169ca9a2dc5154b3959c34d0533b/_embedded_binaries/embedded_tools/jdk/bin/javac -version                                        
-bash: /home/xyz/.cache/bazel/_bazel_xyz/install/6358169ca9a2dc5154b3959c34d0533b/_embedded_binaries/embedded_tools/jdk/bin/javac: cannot execute binary file: Exec format error                           
[xyz@xyz-mac-fc-x86 bazel]$ readelf -h /home/xyz/.cache/bazel/_bazel_xyz/install/6358169ca9a2dc5154b3959c34d0533b/_embedded_binaries/embedded_tools/jdk/bin/javac
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400530
  Start of program headers:          64 (bytes into file)
  Start of section headers:          3312 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         34
  Section header string table index: 31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.