Changeset 7461924 in rtems-tools


Ignore:
Timestamp:
Sep 17, 2012, 12:13:55 AM (8 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
ef4061f
Parents:
aef6d90
Message:

Rename rld-gcc. Add -C option.

Add a -C (also --cc) option to allow the CC to be used when linking to be
provided by the user rather than using the path. This support allows user
who work with the full path to tools rather than the environment to make
use of the linker without them needing to play with environment table.

Rename rld-gcc.[h.cpp] to rld-cc.[h,cpp] because gcc may not be the
only compiler/linker used by the RTEMS project.

Location:
linkers
Files:
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • linkers/main.cpp

    raef6d90 r7461924  
    11/*
    2  * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
     2 * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org>
    33 *
    44 * Permission to use, copy, modify, and/or distribute this software for any
     
    3838
    3939#include <rld.h>
    40 #include <rld-gcc.h>
     40#include <rld-cc.h>
    4141#include <rld-outputter.h>
    4242#include <rld-process.h>
     
    4848
    4949/**
    50  * RTEMS Linker options. This needs to be rewritten to be like gcc where only a
     50 * RTEMS Linker options. This needs to be rewritten to be like cc where only a
    5151 * single '-' and long options is present.
    5252 */
     
    5858  { "map",         no_argument,            NULL,           'M' },
    5959  { "output",      required_argument,      NULL,           'o' },
     60  { "script",      no_argument,            NULL,           'S' },
    6061  { "lib-path",    required_argument,      NULL,           'L' },
    6162  { "lib",         required_argument,      NULL,           'l' },
    6263  { "no-stdlibs",  no_argument,            NULL,           'n' },
    63   { "exec-prefix", required_argument,      NULL,           'E' },
    64   { "march",       required_argument,      NULL,           'a' },
    65   { "mcpu",        required_argument,      NULL,           'c' },
    6664  { "entry",       required_argument,      NULL,           'e' },
    6765  { "define",      required_argument,      NULL,           'd' },
    6866  { "undefined",   required_argument,      NULL,           'u' },
    6967  { "base",        required_argument,      NULL,           'b' },
    70   { "script",      no_argument,            NULL,           'S' },
     68  { "cc",          required_argument,      NULL,           'C' },
     69  { "exec-prefix", required_argument,      NULL,           'E' },
     70  { "march",       required_argument,      NULL,           'a' },
     71  { "mcpu",        required_argument,      NULL,           'c' },
    7172  { NULL,          0,                      NULL,            0 }
    7273};
     
    9293            << " -M        : generate map output (also --map)" << std::endl
    9394            << " -o file   : linker output is written to file (also --output)" << std::endl
     95            << " -S script : linker output is a script file (also --script)" << std::endl
    9496            << " -L path   : path to a library, add multiple for more than" << std::endl
    9597            << "             one path (also --lib-path)" << std::endl
     
    9799            << "             for more than one library (also --lib)" << std::endl
    98100            << " -n        : do not search standard libraries (also --no-stdlibs)" << std::endl
    99             << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl
    100             << " -a march  : machine architecture (also --march)" << std::endl
    101             << " -c cpu    : machine architecture's CPU (also --mcpu)" << std::endl
    102101            << " -e entry  : entry point symbol (also --entry)" << std::endl
    103102            << " -d sym    : add the symbol definition, add multiple with" << std::endl
     
    107106            << " -b elf    : read the ELF file symbols as the base RTEMS kernel" << std::endl
    108107            << "             image (also --base)" << std::endl
    109             << " -S script : linker output is a script file (also --script)" << std::endl;
     108            << " -C file   : execute file as the target C compiler (also --cc)" << std::endl
     109            << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl
     110            << " -a march  : machine architecture (also --march)" << std::endl
     111            << " -c cpu    : machine architecture's CPU (also --mcpu)" << std::endl;
    110112  ::exit (exit_code);
    111113}
     
    166168    std::string         output = "a.out";
    167169    std::string         base_name;
     170    std::string         cc_name;
    168171    bool                script = false;
    169172    bool                standard_libs = true;
     
    176179    while (true)
    177180    {
    178       int opt = ::getopt_long (argc, argv, "hvwVMnSb:E:o:L:l:a:c:e:d:u:", rld_opts, NULL);
     181      int opt = ::getopt_long (argc, argv, "hvwVMnSb:E:o:L:l:a:c:e:d:u:C:", rld_opts, NULL);
    179182      if (opt < 0)
    180183        break;
     
    228231          break;
    229232
     233        case 'C':
     234          if (exec_prefix_set == true)
     235            std::cerr << "warning: exec-prefix ignored when CC provided" << std::endl;
     236          rld::cc::cc = optarg;
     237          break;
     238
    230239        case 'E':
    231240          exec_prefix_set = true;
    232           rld::gcc::exec_prefix = optarg;
     241          rld::cc::exec_prefix = optarg;
    233242          break;
    234243
    235244        case 'a':
    236           rld::gcc::march = optarg;
     245          rld::cc::march = optarg;
    237246          break;
    238247
    239248        case 'c':
    240           rld::gcc::mcpu = optarg;
     249          rld::cc::mcpu = optarg;
    241250          break;
    242251
     
    297306
    298307    /*
    299      * If the exec-prefix is not set by the command line see if it can be
    300      * detected from the object file types. This must be after we have added
    301      * the object files.
    302      */
    303     if (!exec_prefix_set)
    304       rld::gcc::exec_prefix = rld::elf::machine_type ();
     308     * If the full path to CC is not provided and the exec-prefix is not set by
     309     * the command line see if it can be detected from the object file
     310     * types. This must be after we have added the object files because they
     311     * are used when detecting.
     312     */
     313    if (rld::cc::cc.empty () && !exec_prefix_set)
     314      rld::cc::exec_prefix = rld::elf::machine_type ();
    305315
    306316    /*
     
    317327     * Get the standard library paths
    318328     */
    319     rld::gcc::get_standard_libpaths (libpaths);
     329    rld::cc::get_standard_libpaths (libpaths);
    320330
    321331    /*
     
    328338     */
    329339    if (standard_libs)
    330       rld::gcc::get_standard_libs (libraries, libpaths);
     340      rld::cc::get_standard_libs (libraries, libpaths);
    331341
    332342    /*
  • linkers/rld-cc.cpp

    raef6d90 r7461924  
    11/*
    2  * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
     2 * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org>
    33 *
    44 * Permission to use, copy, modify, and/or distribute this software for any
    55 * purpose with or without fee is hereby granted, provided that the above
    66 * copyright notice and this permission notice appear in all copies.
    7  * 
     7 *
    88 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     
    2020
    2121#include <rld.h>
    22 #include <rld-gcc.h>
     22#include <rld-cc.h>
    2323#include <rld-process.h>
    2424
    2525namespace rld
    2626{
    27   namespace gcc
     27  namespace cc
    2828  {
     29    std::string cc;
    2930    std::string exec_prefix;
    3031    std::string march;
     
    4445    make_cc_command (rld::process::arg_container& args)
    4546    {
    46       std::string cmd = "gcc";
    47       if (!exec_prefix.empty ())
    48         cmd = exec_prefix + "-rtems" + rld::rtems_version () + '-' + cmd;
    49       args.push_back (cmd);
     47      /*
     48       * Use the absolute path to CC is provided.
     49       */
     50      if (!cc.empty ())
     51        args.push_back (cc);
     52      else
     53      {
     54        std::string cmd = "gcc";
     55        if (!exec_prefix.empty ())
     56          cmd = exec_prefix + "-rtems" + rld::rtems_version () + '-' + cmd;
     57        args.push_back (cmd);
     58      }
    5059      if (!march.empty ())
    5160        args.push_back ("-march=" + march);
     
    7584      make_cc_command (args);
    7685      args.push_back ("-print-search-dirs");
    77      
     86
    7887      rld::process::tempfile out;
    7988      rld::process::tempfile err;
     
    104113        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
    105114        {
    106           std::cout << "gcc::install: " << install_path << std::endl
    107                     << "gcc::programs: " << programs_path << std::endl
    108                     << "gcc::libraries: " << libraries_path << std::endl;
     115          std::cout << "cc::install: " << install_path << std::endl
     116                    << "cc::programs: " << programs_path << std::endl
     117                    << "cc::libraries: " << libraries_path << std::endl;
    109118        }
    110119      }
     
    122131      make_cc_command (args);
    123132      args.push_back ("-print-file-name=" + name);
    124      
     133
    125134      rld::process::tempfile out;
    126135      rld::process::tempfile err;
     
    133142      {
    134143        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
    135           out.output ("gcc", std::cout, true);
     144          out.output ("cc", std::cout, true);
    136145        out.open ();
    137146        out.get (path);
    138147        out.close ();
    139148        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
    140           std::cout << "gcc::libpath: " << name << " -> " << path << std::endl;
     149          std::cout << "cc::libpath: " << name << " -> " << path << std::endl;
    141150      }
    142151      else
    143152      {
    144         err.output ("gcc", std::cout);
     153        err.output ("cc", std::cout);
    145154      }
    146155    }
     
    154163
    155164    void
    156     get_standard_libs (rld::files::paths& libs, 
     165    get_standard_libs (rld::files::paths& libs,
    157166                       rld::files::paths& libpaths,
    158167                       bool               cplusplus)
     
    169178      {
    170179        if (rld::verbose () >= RLD_VERBOSE_INFO)
    171           std::cout << "gcc::stdlib: " << *lni << std::endl;
     180          std::cout << "cc::stdlib: " << *lni << std::endl;
    172181
    173182        std::string path;
  • linkers/rld-cc.h

    raef6d90 r7461924  
    11/*
    2  * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
     2 * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org>
    33 *
    44 * Permission to use, copy, modify, and/or distribute this software for any
    55 * purpose with or without fee is hereby granted, provided that the above
    66 * copyright notice and this permission notice appear in all copies.
    7  * 
     7 *
    88 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    99 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     
    1919 * @ingroup rtems-ld
    2020 *
    21  * @brief Various calls to GCC.
     21 * @brief Various calls to CC.
    2222 *
    2323 */
    2424
    25 #if !defined (_RLD_GCC_H_)
    26 #define _RLD_GCC_H_
     25#if !defined (_RLD_CC_H_)
     26#define _RLD_CC_H_
    2727
    2828#include <string>
     
    3232namespace rld
    3333{
    34   namespace gcc
     34  namespace cc
    3535  {
    36     extern std::string exec_prefix;    //< The GCC executable prefix.
    37     extern std::string march;          //< The GCC machine architecture.
    38     extern std::string mcpu;           //< The GCC machine CPU.
     36    extern std::string cc;             //< The CC executable.
     37    extern std::string exec_prefix;    //< The CC executable prefix.
     38    extern std::string march;          //< The CC machine architecture.
     39    extern std::string mcpu;           //< The CC machine CPU.
    3940
    40     extern std::string install_path;   //< The GCC reported install path.
    41     extern std::string programs_path;  //< The GCC reported programs path.
    42     extern std::string libraries_path; //< The GCC reported libraries path.
    43    
     41    extern std::string install_path;   //< The CC reported install path.
     42    extern std::string programs_path;  //< The CC reported programs path.
     43    extern std::string libraries_path; //< The CC reported libraries path.
     44
    4445    /**
    4546     * Get the standard libraries paths from the compiler.
    4647     */
    4748    void get_standard_libpaths (rld::files::paths& libpaths);
    48    
     49
    4950    /**
    5051     * Get the standard libraries. Optionally add the C++ library.
    5152     */
    52     void get_standard_libs (rld::files::paths& libs, 
     53    void get_standard_libs (rld::files::paths& libs,
    5354                            rld::files::paths& libpaths,
    5455                            bool               cpp = false);
    55    
     56
    5657  }
    5758}
  • linkers/wscript

    raef6d90 r7461924  
    8686                          'rld-elf.cpp',
    8787                          'rld-files.cpp',
    88                           'rld-gcc.cpp',
     88                          'rld-cc.cpp',
    8989                          'rld-outputter.cpp',
    9090                          'rld-process.cpp',
Note: See TracChangeset for help on using the changeset viewer.