Centos7 mini system openjdk9 source code compilation

The premise is to read this blog post https://my.oschina.net/u/3829817/blog/1795177

source of openjdk

According to the GNU protocol , also known as the Genuine Project, it was publicly launched by Richard Stallman on September 27, 1983. Its goal is to create a completely free operating system. Richard Stallman first announced the news on the net.unix-wizards newsgroup, along with articles such as the "GNU Manifesto" explaining why the project was launched. One of the reasons was to "recreate the spirit of cooperation and mutual assistance in the software industry." To ensure that GNU software is free to "use, copy, modify, and distribute", all GNU software has the terms of an agreement that grants all rights to anyone without adding any restrictions to others, the GNU General Public License (GNU General Public License). General Public License, GPL). That is "anti-copyright" (or Copyleft) concept. Therefore, Sun officially released OpenJDK on April 15, 2009. Oracle took over the project after acquiring Sun in 2010.

Oracle JDK only releases binary installation packages, while OpenJDK only releases source code.

The necessity of learning openjdk

The principle of von Neumann machine

  • A computer consists of five parts: arithmetic unit , controller, memory , input device and output device .
  • In the method of storing programs, the program and data are placed in the same memory, and the instructions and data can be sent to the operator for operation, that is, the program composed of the instructions can be modified.
  • Data is represented in binary code.
  • An instruction consists of an opcode and an address code .
  • The instructions are stored in the memory in the order of execution, and the unit address of the instruction to be executed is indicated by the instruction counter , which is generally incremented in order, but can be changed according to the operation result or external conditions.
  • The machine is centered on the arithmetic unit, and the data transmission between the input and output devices and the memory all pass through the arithmetic unit.

 From this, we know that the operation of the equipment on the computer requires binary code, that is, the combination of 0 and 1, and the part of the computer that processes the operation is the operator and the controller, which is the current microprocessor CPU, so there is a machine code, a machine The code is to give instructions to the CPU, the machine is easy to recognize, and the human programming through the machine code is too complicated, so the intelligent human maps the binary code of the machine code 0001, 0010 into a fixed symbol, such as 0001 for read, 0010 for add, so there is assembly language. The operation instructions formed by assembly language are the operation instructions of the CPU, so each CPU has its own operating specifications, so there is the 8086 processor, the Intel 8086 central processing unit launched by Intel in 1978 It first appeared in the Intel 8008 processor, and the 8008 was developed from the Intel 4004 . The 8086 was chosen for the IBM PC three years later , after which the x86 became the standard platform for personal computers, the most successful CPU architecture of all time. 

The 8086 is a 16-bit processor; followed by a 32-bit 80386 processor, until 2003, AMD developed a 64-bit extension to this architecture and named it AMD64 . Later , Intel also introduced a compatible processor and named it Intel 64. The two are generally collectively referred to as x86-64 or x64 , creating the 64-bit era of x86. Here 16 bits, 32 bits and 64 bits represent the number of registers.

First, the instruction set formed based on the x86 architecture is still too complicated for human beings. Second, each CPU will have different instruction sets, so that the software written based on a certain CPU can only be used by a specific CPU, so based on x86 Assembly language was born on the instruction set of the architecture. Assembly language is still not very friendly to people, so human beings invented high-level languages, such as C and C++ languages, so that high-level languages ​​and assembly languages ​​directly map the instruction set, so in this mapping The compiler was born in between, and this is the principle of compilation.

(source language) source program → compiler → object machine code program (object code )

Later, humans invented the object-oriented programming language, which is more in line with human thinking logic, so the protagonist was born-- java super high-level language

Later, the programmers of sun company encapsulated JAVA, C , and C++ through JNI to form JDK. JNI is the abbreviation of Java Native Interface. It provides several APIs to realize the communication between Java and other languages ​​(mainly C & C++ ) . So in 2009, sun company released the jdk source code to the public, and openjdk was born.

Compilation of openjdk

I compiled openjdk9

openjdk9 source address http://hg.openjdk.java.net/jdk9

This is a version tree, a code hosting platform based on Mercurial , similar to github and open source China's code cloud .

Open the local centos7 virtual machine, please ensure that the local computer is connected to the Internet and the network speed is good. If the internet speed is poor, find a place with good internet speed, otherwise you will cry. I have already cried.

yum install mercurial

Download the openjdk9 compilation guide project source code, under this source code are the bash scripts and compilation guides that need to compile and download the openjdk9 source code

openjdk9 guide project download address http://hg.openjdk.java.net/jdk9/jdk9/

Click zip to download to local

Then unzip the zip package into the \common\doc directory

Open building.html with a browser and translate it into Chinese

Then start your show according to the guide

It is best to log in to the centos7 virtual machine with root privileges

clone the guide project to the /opt directory 

hg clone http://hg.openjdk.java.net/jdk9/jdk9
cd jdk9
bash get_source.sh

Please be patient and wait for the download of the source code to complete

Download compilers, external libraries and header files

sudo yum groupinstall "Development Tools"

Then install boot jdk8

sudo yum install java-1.8.0-openjdk-devel

run configuration parameters

bash configure --with-target-bits=64 --disable-warnings-as-errors --with-debug-level=slowdebug --with-boot-jdk=/usr/jdk1.8.0_161

Change this --with-boot-jdk=/usr/jdk1.8.0_161 to your own jdk absolute path

Compile openjdk9 source code

make images

 Go to the root directory and modify the jdk environment variable to your own path./build/*/images/jdk/

vi /etc/profile
source /etc/profile
java -version

Verification succeeded

Now start debugging openjdk9!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324407120&siteId=291194637