Chapter One the Mac OS compiler openjdk 7

Source: Internet
Author: User

Like the author of the book, I compiled the OPENJDK 7. The process is also encountered a lot of pits, consulted a lot of information, tried to use JDK8,JDK7,JDK6, the final use of jdk7u71 compiled successfully, the following record the process, so that others can learn from. First, the preparatory work:

1. Install Xcode, download directly from the App Store, and command line tools


2. Download Ant,mac will bring Ant, in/usr/local/cellar/ant/1.9.7, if not to go to the official website next, I was the next one. Then, because the ant path in jdk/src/macosx/native/jobjc/jobjc.xcodeproj/project.pbxproj and Jdk/make/java/jobjc/makefile files is written dead to/usr/ Bin/ant, so to make a soft connection under the Usr/bin, was pit for a long time:

Ln-s/users/jiangchao08/downloads/apache-ant-1.9.7/bin/ant/usr/bin/ant


3. Download openjdk 7 zip file, then unzip, address: https://jdk7.java.net/source.html


4. Download Oracle JDK 7, I downloaded the 7u71 version, address:http://www.oracle.com/technetwork/java/javase/downloads/ Java-archive-downloads-javase7-521261.html


5. Install Xquartz


6. Do not set Java_home, CLASSPATH environment variables, you can use the last line unset Java_home, unset classpath to comment out


Second, the environment variable settings:

below is the configuration of my environment variables, configured in the ~/.bash_profile file;

Export m2_home=/users/jiangchao08/downloads/apache-maven-3.3.9
Export ant_home=/users/jiangchao08/downloads/ apache-ant-1.9.7
export path= $PATH: $M 2_home/bin: $ANT _home/bin:/usr/bin
Export alt_bootdir=/library/java/ Javavirtualmachines/jdk1.7.0_71.jdk/contents/home
export lang=c
export Compiler_warnings_fatal=false
Export Cc=clang
export compiler_warnings_fatal=false
export use_clang=true export
lp64=1
Export Build_deploy=false
export arch_data_model=64
export lflags= '-xlinker-lc++-lstdc++ '
export Hotspot_build_jobs=8
export use_precompiled_header=true
export show_all_warnings=false
Export Incremental_build=true
export skip_debug_build=false
export skip_fastdebug_build=true
unset Java_ Home

before the formal compilation, make sanity, how to succeed, and then formally compile the OPENJDK path to use the command: Make Debug_build


third, the problems encountered: because I've tried many versions of JDK, where I've documented all the bugs that appear, and if you compile Openjdk7, it's very not recommended to use Oracle JDK8, because there are a lot of classes that can't be found, or methods can't be found. After all, OPENJDK7 has been for years. It is recommended that Oracle JDK6 and Oracle JDK7 be used to compile OPENJDK 7:

1.error:the Compiler version is undefined.

Error:freetype version  2.3.0  or higher is required.

(1) The first error, because now Xcode has no own gcc, so link:

sudo ln-s GCC/APPLICATIONS/XCODE.APP/CONTENTS/DEVELOPER/USR/BIN/LLVM-GCC

(2) The second error, because the FreeType version is too low, so I was directly installed Xquartz


2. Build FAILED

/home/xlf/jdk7u-dev/langtools/make/build.xml:452:the following error occurred while executing this line:/home/xlf/ Jdk7u-dev/langtools/make/build.xml:795:compile failed;   The compiler error output for details. WORKAROUND: Replace Oracle JDK version 8 with JDK 7 for resolution
3. Garbled problem:

# specific error
openjdk/build/. /build-debug/corba/gensrc/org/omg/portableserver/adapteractivatoroperations.java:8:´íîó:±àâëasciiµä
    ²»¿ Éó³éäxö û
* 2016?? 7?? 12?? ?????? ???? 05?? 39?? 22?? CST

# Solutions Find
build-debug/corba/gensrc/org/-name ' *.java ' | While read P. Do native2ascii-encoding UTF-8 $p &G T TMPJ; MV TMPJ $p; Done
Export _JAVA_OPTIONS=-DFILE.ENCODING=ASCII
4. Clang does not support parameter-fpch-deps

# specific error Clang:error:unknown argument: '-fpch-deps ' # solution 1. Find the corresponding configuration file first. -type f! -name "*.java" | Xargs grep-r "\-fpch\-deps" 1.1 matching search results are as follows (the Mac comes from BSD, select BSD)./hotspot/make/bsd/makefiles/gcc.make:depflags =- FPCH-DEPS-MMD-MP-MF $ (Dep_dir)/$ (@:%=%.d)./hotspot/make/linux/makefiles/gcc.make:depflags =-FPCH-DEPS-MMD-MP-MF $ (Dep_dir)/$ (@:%=%.d)./hotspot/make/solaris/makefiles/gcc.make:depflags =-FPCH-DEPS-MMD-MP-MF $ (DEP_DIR)/$ (@:%=%.
d) 2 Modify Hotspot/make/bsd/makefiles/gcc.make 2.1 comment 216-218 Line # flags for generating make dependency flags. # IFNEQ ("${cc_ver_major}", "2") # Depflags =-FPCH-DEPS-MMD-MP-MF $ (dep_dir)/$ (@:%=%.d) # endif 2.2 Add the following code under 218 lines DEPFL AGS =-MMD-MP-MF $ (dep_dir)/$ (@:%=%.d) ifeq ($ (Use_clang),) Ifneq ($ (cc_ver_major), 2) depflags + =-fpch-deps en DIF endif 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.