[gn build] Fix link with ld.bfd and gold.
lld's symbol resolution algorithm makes it not depend on
the order of object files and libraries, but ld.bfd and
gold require listing dependencies later on the link line.
Put {{libs}} after {{inputs}} so that e.g. -lpthreads
appears after the object files, not before it.
Differential Revision: https://reviews.llvm.org/D81035
			
			
This commit is contained in:
		
							parent
							
								
									7f50c15be5
								
							
						
					
					
						commit
						a946cb1813
					
				| 
						 | 
					@ -55,10 +55,10 @@ template("unix_toolchain") {
 | 
				
			||||||
    tool("solink") {
 | 
					    tool("solink") {
 | 
				
			||||||
      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
 | 
					      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
 | 
				
			||||||
      if (current_os == "mac") {
 | 
					      if (current_os == "mac") {
 | 
				
			||||||
        command = "$ld -shared {{ldflags}} -o $outfile {{libs}} {{inputs}}"
 | 
					        command = "$ld -shared {{ldflags}} -o $outfile {{inputs}} {{libs}}"
 | 
				
			||||||
        default_output_extension = ".dylib"
 | 
					        default_output_extension = ".dylib"
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        command = "$ld -shared {{ldflags}} -Wl,-z,defs -Wl,-soname,{{target_output_name}}{{output_extension}} -o $outfile {{libs}} {{inputs}}"
 | 
					        command = "$ld -shared {{ldflags}} -Wl,-z,defs -Wl,-soname,{{target_output_name}}{{output_extension}} -o $outfile {{inputs}} {{libs}}"
 | 
				
			||||||
        default_output_extension = ".so"
 | 
					        default_output_extension = ".so"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      description = "SOLINK $outfile"
 | 
					      description = "SOLINK $outfile"
 | 
				
			||||||
| 
						 | 
					@ -71,10 +71,10 @@ template("unix_toolchain") {
 | 
				
			||||||
    tool("solink_module") {
 | 
					    tool("solink_module") {
 | 
				
			||||||
      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
 | 
					      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
 | 
				
			||||||
      if (current_os == "mac") {
 | 
					      if (current_os == "mac") {
 | 
				
			||||||
        command = "$ld -shared {{ldflags}} -Wl,-flat_namespace -Wl,-undefined,suppress -o $outfile {{libs}} {{inputs}}"
 | 
					        command = "$ld -shared {{ldflags}} -Wl,-flat_namespace -Wl,-undefined,suppress -o $outfile {{inputs}} {{libs}}"
 | 
				
			||||||
        default_output_extension = ".dylib"
 | 
					        default_output_extension = ".dylib"
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        command = "$ld -shared {{ldflags}} -Wl,-soname,{{target_output_name}}{{output_extension}} -o $outfile {{libs}} {{inputs}}"
 | 
					        command = "$ld -shared {{ldflags}} -Wl,-soname,{{target_output_name}}{{output_extension}} -o $outfile {{inputs}} {{libs}}"
 | 
				
			||||||
        default_output_extension = ".so"
 | 
					        default_output_extension = ".so"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      description = "SOLINK $outfile"
 | 
					      description = "SOLINK $outfile"
 | 
				
			||||||
| 
						 | 
					@ -86,9 +86,9 @@ template("unix_toolchain") {
 | 
				
			||||||
    tool("link") {
 | 
					    tool("link") {
 | 
				
			||||||
      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
 | 
					      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
 | 
				
			||||||
      if (current_os == "mac") {
 | 
					      if (current_os == "mac") {
 | 
				
			||||||
        command = "$ld {{ldflags}} -o $outfile {{libs}} {{inputs}}"
 | 
					        command = "$ld {{ldflags}} -o $outfile {{inputs}} {{libs}}"
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        command = "$ld {{ldflags}} -o $outfile {{libs}} -Wl,--start-group {{inputs}} -Wl,--end-group"
 | 
					        command = "$ld {{ldflags}} -o $outfile -Wl,--start-group {{inputs}} -Wl,--end-group {{libs}}"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      description = "LINK $outfile"
 | 
					      description = "LINK $outfile"
 | 
				
			||||||
      outputs = [ outfile ]
 | 
					      outputs = [ outfile ]
 | 
				
			||||||
| 
						 | 
					@ -245,7 +245,7 @@ toolchain("win") {
 | 
				
			||||||
    dllfile = "$outprefix{{output_extension}}"
 | 
					    dllfile = "$outprefix{{output_extension}}"
 | 
				
			||||||
    libfile = "$outprefix.lib"
 | 
					    libfile = "$outprefix.lib"
 | 
				
			||||||
    pdbfile = "$outprefix.pdb"
 | 
					    pdbfile = "$outprefix.pdb"
 | 
				
			||||||
    command = "$link /nologo /dll {{ldflags}} /out:$dllfile /implib:$libfile /pdb:$pdbfile {{libs}} {{inputs}}"
 | 
					    command = "$link /nologo /dll {{ldflags}} /out:$dllfile /implib:$libfile /pdb:$pdbfile {{inputs}} {{libs}} "
 | 
				
			||||||
    description = "LINK $dllfile"
 | 
					    description = "LINK $dllfile"
 | 
				
			||||||
    link_output = libfile
 | 
					    link_output = libfile
 | 
				
			||||||
    depend_output = libfile
 | 
					    depend_output = libfile
 | 
				
			||||||
| 
						 | 
					@ -272,7 +272,7 @@ toolchain("win") {
 | 
				
			||||||
    outprefix = "{{output_dir}}/{{target_output_name}}"
 | 
					    outprefix = "{{output_dir}}/{{target_output_name}}"
 | 
				
			||||||
    dllfile = "$outprefix{{output_extension}}"
 | 
					    dllfile = "$outprefix{{output_extension}}"
 | 
				
			||||||
    pdbfile = "$outprefix.pdb"
 | 
					    pdbfile = "$outprefix.pdb"
 | 
				
			||||||
    command = "$link /nologo /dll {{ldflags}} /out:$dllfile /pdb:$pdbfile {{libs}} {{inputs}}"
 | 
					    command = "$link /nologo /dll {{ldflags}} /out:$dllfile /pdb:$pdbfile {{inputs}} {{libs}} "
 | 
				
			||||||
    description = "LINK_MODULE $dllfile"
 | 
					    description = "LINK_MODULE $dllfile"
 | 
				
			||||||
    outputs = [ dllfile ]
 | 
					    outputs = [ dllfile ]
 | 
				
			||||||
    lib_switch = ""
 | 
					    lib_switch = ""
 | 
				
			||||||
| 
						 | 
					@ -286,7 +286,7 @@ toolchain("win") {
 | 
				
			||||||
    outprefix = "{{output_dir}}/{{target_output_name}}"
 | 
					    outprefix = "{{output_dir}}/{{target_output_name}}"
 | 
				
			||||||
    outfile = "$outprefix{{output_extension}}"
 | 
					    outfile = "$outprefix{{output_extension}}"
 | 
				
			||||||
    pdbfile = "$outprefix.pdb"
 | 
					    pdbfile = "$outprefix.pdb"
 | 
				
			||||||
    command = "$link /nologo {{ldflags}} /out:$outfile /pdb:$pdbfile {{libs}} {{inputs}}"
 | 
					    command = "$link /nologo {{ldflags}} /out:$outfile /pdb:$pdbfile {{inputs}} {{libs}}"
 | 
				
			||||||
    description = "LINK $outfile"
 | 
					    description = "LINK $outfile"
 | 
				
			||||||
    outputs = [ outfile ]
 | 
					    outputs = [ outfile ]
 | 
				
			||||||
    lib_switch = ""
 | 
					    lib_switch = ""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue