123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- # Copyright 2021 The Chromium Authors. All rights reserved.
- # Use of this source code is governed by a BSD-style license that can be
- # found in the LICENSE file.
- # This file is based on gcc_toolchain.gni and customized for z/OS.
- import("//build/toolchain/gcc_toolchain.gni")
- toolchain("s390x") {
- cc = "xlclang"
- cxx = "xlclang++"
- asm = "xlclang"
- ar = "ar"
- ld = cxx
- toolchain_args = {
- current_cpu = "s390x"
- current_os = "zos"
- }
- rebuild_string = ""
- default_shlib_extension = ".so"
- default_shlib_subdir = ""
- extra_cflags = ""
- extra_cppflags = ""
- extra_cxxflags = ""
- extra_asmflags = ""
- extra_ldflags = ""
- # These library switches can apply to all tools below.
- lib_switch = "-l"
- lib_dir_switch = "-L"
- # Object files go in this directory.
- object_subdir = "{{target_out_dir}}/{{label_name}}"
- tool("cc") {
- depfile = "{{output}}.d"
- command = "$cc -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}${extra_cflags} -c {{source}} -o {{output}}"
- depsformat = "gcc"
- description = "CC {{output}}"
- outputs = [ "$object_subdir/{{source_name_part}}.o" ]
- }
- tool("cxx") {
- depfile = "{{output}}.d"
- command = "$cxx -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} -o {{output}}"
- depsformat = "gcc"
- description = "CXX {{output}}"
- outputs = [ "$object_subdir/{{source_name_part}}.o" ]
- }
- tool("asm") {
- # Just use the C compiler to compile assembly.
- depfile = "{{output}}.d"
- command = "$asm -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}}${extra_asmflags} -c {{source}} -o {{output}}"
- depsformat = "gcc"
- description = "ASM {{output}}"
- outputs = [ "$object_subdir/{{source_name_part}}.o" ]
- }
- tool("alink") {
- command = "$ar {{arflags}} -r -c -s {{output}} {{inputs}}"
- # Remove the output file first so that ar doesn't try to modify the
- # existing file.
- command = "rm -f {{output}} && $command"
- # Almost all targets build with //build/config/compiler:thin_archive which
- # adds -T to arflags.
- description = "AR {{output}}"
- outputs = [ "{{output_dir}}/{{target_output_name}}{{output_extension}}" ]
- # Shared libraries go in the target out directory by default so we can
- # generate different targets with the same name and not have them collide.
- default_output_dir = "{{target_out_dir}}"
- default_output_extension = ".a"
- output_prefix = "lib"
- }
- tool("solink") {
- soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
- sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir.
- xfile = "{{output_dir}}/{{target_output_name}}.x"
- rspfile = sofile + ".rsp"
- # These variables are not built into GN but are helpers that
- # implement (1) linking to produce a .so, (2) extracting the symbols
- # from that file (3) if the extracted list differs from the existing
- # .TOC file, overwrite it, otherwise, don't change it.
- link_command = "$ld -Wl,DLL {{ldflags}}${extra_ldflags} -o \"$sofile\" `cat $rspfile`"
- solink_wrapper =
- rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
- command = "$python_path \"$solink_wrapper\" --output=\"$sofile\" -- $link_command"
- rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
- description = "SOLINK $sofile"
- # Use this for {{output_extension}} expansions unless a target manually
- # overrides it (in which case {{output_extension}} will be what the target
- # specifies).
- default_output_extension = default_shlib_extension
- default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"
- output_prefix = "lib"
- # Since the above commands only updates the .TOC file when it changes, ask
- # Ninja to check if the timestamp actually changed to know if downstream
- # dependencies should be recompiled.
- restat = true
- # Tell GN about the output files. It will link to the sofile but use the
- # tocfile for dependency management.
- outputs = [ xfile ]
- outputs += [ sofile ]
- link_output = xfile
- depend_output = xfile
- }
- tool("solink_module") {
- soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
- sofile = "{{output_dir}}/$soname"
- xfile = "{{output_dir}}/{{target_output_name}}.x"
- rspfile = sofile + ".rsp"
- command = "$ld {{ldflags}}${extra_ldflags} -o \"$sofile\" `cat $rspfile`"
- rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
- description = "SOLINK_MODULE $sofile"
- default_output_dir = "{{root_out_dir}}${default_shlib_subdir}"
- output_prefix = "lib"
- outputs = [ xfile ]
- outputs += [ sofile ]
- }
- tool("link") {
- exename = "{{target_output_name}}{{output_extension}}"
- outfile = "{{output_dir}}/$exename"
- rspfile = "$outfile.rsp"
- default_output_dir = "{{root_out_dir}}"
- link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$outfile\" `cat $rspfile` {{solibs}} {{libs}}"
- link_wrapper =
- rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
- command = "$python_path \"$link_wrapper\" --output=\"$outfile\" -- $link_command"
- description = "LINK $outfile"
- rspfile_content = "{{inputs}}"
- outputs = [ outfile ]
- }
- # These two are really entirely generic, but have to be repeated in
- # each toolchain because GN doesn't allow a template to be used here.
- # See //build/toolchain/toolchain.gni for details.
- tool("stamp") {
- command = stamp_command
- description = stamp_description
- }
- tool("copy") {
- command = copy_command
- description = copy_description
- }
- }
|