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

Closed
shodow opened this issue Aug 30, 2017 · 6 comments
Closed

Compilation error on 32 bit machine #3643

shodow opened this issue Aug 30, 2017 · 6 comments

Comments

@shodow
Copy link

shodow commented Aug 30, 2017

When i run ./compile.sh 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/CPU.java (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
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@aehlig
Copy link
Contributor

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: https://svnweb.freebsd.org/ports/head/devel/bazel/files/extra-i386_src_BUILD?revision=447714&view=markup (the type fix also in that patch is upstream, but didn't make it into 0.5.4).

@shodow
Copy link
Author

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.

@shodow
Copy link
Author

shodow commented Aug 31, 2017

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

@vladmos
Copy link
Member

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 as completed Sep 1, 2017
@likan999
Copy link

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 ./compile.sh succeeds, but the resulting bazel can't be used to build scripts/packages:with-jdk/install.sh.

[xyz@xyz-mac-fc-x86 bazel]$ output/bazel build scripts/packages:with-jdk/install.sh                                                                               
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/install.sh' 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, ./compile.sh succeeds, and output/bazel build //scripts/packages:with-jdk/install.sh also succeeds, but when executing the result install.sh, 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/install.sh --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:
   https://github.com/bazelbuild/bazel/releases

# Binary package at HEAD (@)
   - [Commit](https://github.com/bazelbuild/bazel/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

@IT-Wangzi
Copy link

IT-Wangzi commented Jul 22, 2022

I hava the same issue, my os is also ubuntu 16.04 32bit LTS . but the bazel version is 0.21.0,
i follow #3382 to modify src/main/java/com/google/devtools/build/lib/util/CPU.java (line 23-29)and
tools/cpp/lib_cc_configure.bzl 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.of());

and #38c5241 to edit the file src/BUILD (line 173-174) into
"//conditions:default": [
"//src/java_tools/singlejar:SingleJar_deploy.jar",
it's not the same changing compared with the author, but it works. Then use the commod env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh to run and it succeed.

屏幕截图 2022-07-22 224417
cust@VirtualBox:~$ bazel version
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
INFO: Invocation ID: c15e8e80-6f16-4f6b-9834-cf1c32768d2b
Build label: 0.21.0- (@non-git)
Build target: bazel-out/piii-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jul 22 13:21:06 2022 (1658496066)
Build timestamp: 1658496066
Build timestamp as int: 1658496066

Hope to help others.

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

5 participants