[Original] DistCC source code Research 4

Source: Internet
Author: User

Author: Zhu Jincan

Source: http://blog.csdn.net/clever101

 

In DistCC source code study 3, I mentioned the dcc_build_somewhere_timed function, which is used to create a compilation process. Let's take a look at how this function creates a compilation process.

 

The dcc_build_somewhere_timed function mainly calls the dcc_build_somewhere function. Next we will carefully analyze the dcc_build_somewhere function.

 

The dcc_build_somewhere function is complex. It first calls the dcc_expand_preprocessor_options function to parse the GCC compilation options, and then calls the dcc_discrepancy_filename function to obtain a file name that is different from the local file and the server (this step is hard to understand, but it should not be important ). Then call the dcc_scan_args function to parse other command line parameters of diatcc. Call the dcc_make_tmpnam function to create a temporary file to save server errors. The next step is to call the dcc_pick_host_from_list_and_lock_it function to obtain and lock all the compilation servers. The compilation server here includes the remote compilation server and the local compilation server (that is, the local machine ). Here we will explain how DistCC works: DistCC will be preprocessedCodeIt is sent to another specified machine in the network. The distccd daemon ensures that the compilation occurs on a remote machine. DistCC is designed to be used with the parallel compilation (-j) option of GNU make. DistCC itself is not a compiler; it is only used as a front-end of G ++. Almost all options of G ++ can be passed to DistCC as is. Therefore, local machines need to know which servers should the compilation process be distributed. Based on your shell, issue a command similar to the following command:

 

Export distcc_hosts = 'localhost Tintin Asterix pogo'

 

Tintin, Asterix, and Pogo are other hosts that can reside in the compilation process, while localhost is a local computer.

You can also choose not to use the Export command. You can create a file named hosts and put the server name in the file. The names are separated by spaces. Copy the file to the $ home/. DistCC folder.

 

Therefore, the compilation server can be obtained in two ways: by obtaining the distcc_hosts value of the environment variable or by reading the host file.

 

In the dcc_pick_host_from_list_and_lock_it function, call the dcc_get_hostlist function to obtain all the compilation servers and call the dcc_remove_disliked function to determine whether the obtained compilation server is available. The unavailable server is deleted from the server list. I think this can be improved to scan machines in the same network segment. If an available compilation server is found, add it to the server list. Incredibuild seems to be implemented in this way. Finally, call the dcc_lock_one function to find a compiler to run distributed compilation by interpreting the local State (which can be a remote server or local server, and what is the role of dcc_lock_one? Are you looking for a server to create a compilation process ?). This article will be analyzed here for the time being.

 

References:

 

1. Distributed Compilation

Author: clever101 posted on 12:56:49 Original article link Read: 194 comments: 0 views comments

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.