59 #include <boost/algorithm/string/classification.hpp> 60 #include <boost/algorithm/string/predicate.hpp> 62 #include "config_HAVE_I386_CLANG16_COMPILER.hpp" 63 #include "config_PANDA_DATA_INSTALLDIR.hpp" 64 #include "config_RELEASE.hpp" 66 #define OPT_PRINT_FILE_NAME 256 67 #define OPT_INCLUDE 257 68 #define OPT_ISYSTEM 258 72 #define OPT_IQUOTE 262 73 #define OPT_ISYSROOT 263 74 #define OPT_IMULTILIB 264 75 #define OPT_IPLUGINDIR 265 76 #define OPT_MINUS_INCLUDE 266 77 #define OPT_START_GROUP 267 78 #define OPT_END_GROUP 268 79 #define OPT_MINUS_MAP 269 80 #define OPT_GC_SECTIONS 270 102 {
"MF", required_argument,
nullptr,
OPT_MF},
103 {
"MT", required_argument,
nullptr,
OPT_MT},
104 {
"MQ", required_argument,
nullptr,
OPT_MQ},
111 {
nullptr, 0,
nullptr, 0}};
121 int next_option = getopt_long_only(
argc,
argv, short_options, long_options, &option_index);
124 if(next_option == -1)
146 if(optarg ==
nullptr)
154 std::string parameter(optarg);
157 setOption(OPT_gcc_standard, parameter.substr(parameter.find(
'=') + 1));
168 std::string gcc_extra_options;
169 if(optarg !=
nullptr)
171 gcc_extra_options =
"-M" + std::string(optarg);
175 gcc_extra_options =
"-M";
179 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
181 setOption(OPT_gcc_extra_options, gcc_extra_options);
186 if(std::string(optarg).find(
"plugindir=") == 0)
188 setOption(OPT_gcc_plugindir, std::string(optarg).substr(10));
192 std::string gcc_extra_options;
193 gcc_extra_options =
"-i" + std::string(optarg);
196 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
198 setOption(OPT_gcc_extra_options, gcc_extra_options);
204 std::string gcc_extra_options =
"-include " + std::string(optarg);
207 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
209 setOption(OPT_gcc_extra_options, gcc_extra_options);
214 std::string parameter(optarg);
215 std::string gcc_extra_options =
"-n" + std::string(parameter);
218 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
220 setOption(OPT_gcc_extra_options, gcc_extra_options);
230 std::string parameter(optarg);
231 std::string gcc_extra_options =
"-MF " + std::string(parameter);
234 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
236 setOption(OPT_gcc_extra_options, gcc_extra_options);
241 std::string parameter(optarg);
242 std::string gcc_extra_options =
"-MT " + std::string(parameter);
245 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
247 setOption(OPT_gcc_extra_options, gcc_extra_options);
252 std::string parameter(optarg);
253 std::string gcc_extra_options =
"-MQ " + std::string(parameter);
256 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
258 setOption(OPT_gcc_extra_options, gcc_extra_options);
263 std::string gcc_extra_options =
"-x " + std::string(optarg);
266 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
268 setOption(OPT_gcc_extra_options, gcc_extra_options);
273 std::string gcc_extra_options =
"-t";
276 gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) +
" " + gcc_extra_options;
278 setOption(OPT_gcc_extra_options, gcc_extra_options);
284 getOption<CompilerWrapper_OptimizationSet>(OPT_gcc_optimization_set);
288 Wrap->QueryCompilerConfig(
"--print-file-name=" + std::string(optarg));
306 bool exit_success =
false;
307 bool res = ManageGccOptions(next_option, optarg);
325 if(
isOption(OPT_write_parameter_xml))
327 const auto file_name = getOption<std::string>(OPT_write_parameter_xml);
334 if(std::filesystem::path(
argv[optind]).extension() ==
".o")
336 std::string object_files;
343 else if(std::filesystem::path(
argv[optind]).extension() ==
".a")
345 std::string archive_files;
354 std::string input_file;
373 const auto default_compiler = getOption<CompilerWrapper_CompilerTarget>(OPT_default_compiler);
374 const auto flag_cpp =
isOption(OPT_input_format) &&
375 getOption<Parameters_FileFormat>(OPT_input_format) == Parameters_FileFormat::FF_CPP;
379 std::string includes =
384 includes = getOption<std::string>(OPT_gcc_includes) +
" " + includes;
400 else if(!
isOption(OPT_gcc_standard))
412 #if HAVE_I386_CLANG16_COMPILER 415 std::string gcc_warnings;
420 const auto addWarning = [&](
const std::string& warn) {
421 if(gcc_warnings.find(boost::replace_first_copy(warn,
"no-",
"")) == std::string::npos)
426 addWarning(
"no-incompatible-function-pointer-types");
427 addWarning(
"no-implicit-function-declaration");
428 addWarning(
"no-int-conversion");
429 setOption(OPT_gcc_warnings, gcc_warnings);
436 os <<
"Usage: " << getOption<std::string>(OPT_program_name)
437 <<
" [options] <input_file1> [<input_file2> ... <input_fileN>]" << std::endl;
444 os <<
" -o=<file> Specify the output file name\n" 446 PrintGccOptionsUsage(os);
452 os <<
"********************************************************************************" << std::endl;
453 os <<
" _ _" << std::endl;
454 os <<
" | |_ _ __ ___ ___ _ __ __ _ _ __ __| | __ _ __ _ ___ ___" << std::endl;
455 os << R
"( | __| '__/ _ \/ _ \_____| '_ \ / _` | '_ \ / _` |/ _` |_____ / _` |/ __/ __|)" << std::endl; 456 os << " | |_| | | __/ __/_____| |_) | (_| | | | | (_| | (_| |_____| (_| | (_| (__" << std::endl;
457 os << R
"( \__|_| \___|\___| | .__/ \__,_|_| |_|\__,_|\__,_| \__, |\___\___|)" << std::endl; 458 os << " |_| |___/" << std::endl;
459 os <<
"********************************************************************************" << std::endl;
476 setOption(OPT_frontend_statistics,
false);
482 setOption(OPT_gcc_m32_mx32,
"-m32 -mno-sse2");
483 setOption(OPT_without_transformation,
true);
492 setOption(OPT_gcc_include_sysdir,
false);
void write_xml_configuration_file(const std::string &filename)
Write an XML configuration file with the parameters actually stored.
int exit_code
NOTE: this file must be included only by source code of the executable (i.e., the file with the main)...
static int getCompatibleCompilers()
void setOption(const std::string &name, const G value)
Sets the value of an option.
File containing functions and utilities to support the printing of debug messagges.
#define OUTPUT_LEVEL_NONE
no output print is performed.
#define STR_CST_string_separator
The character used to separate concatenated string.
char **const argv
The input parameters;.
#define COMMON_SHORT_OPTIONS_STRING
define the default tool short option string
#define OPT_MINUS_INCLUDE
int Exec() override
Execute parameter parsing.
static int getDefaultCompiler()
Base class to model interfaces for high-level synthesis.
static bool isCurrentOrNewer(CompilerWrapper_CompilerTarget ct, CompilerWrapper_CompilerTarget compare)
static bool isGccCheck(CompilerWrapper_CompilerTarget ct)
Include a set of utilities used to manage CPU time measures.
CompilerWrapper_OptimizationSet
Possible optimization sets.
void PrintUsage(std::ostream &os) const
Print the usage of this tool = PrintHeader() + PrintHelp()
Auxiliary methods for manipulating string.
bool starts_with(const std::string &str, const std::string &pattern)
#define GCC_SHORT_OPTIONS_STRING
define the GCC short option string
#define PARAMETER_PARSED
An integer value to return if parameters have been right parsed.
virtual void CheckParameters()=0
Checks the compatibility among the different parameters and determines the implications.
redefinition of set to manage ordered/unordered structures
utility function used to read files.
This file collects some utility functions and macros.
#define DEBUG_LEVEL_NONE
no debugging print is performed.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
#define COMMON_LONG_OPTIONS
define default TOOL long options
tree_panda_gcc_parameter(const std::string &program_name, int argc, char **const argv)
Constructor.
void CheckParameters() override
Checks parameter values to set implicit one.
std::string GetPath(std::filesystem::path path)
refcount< CompilerWrapper > CompilerWrapperRef
Refcount definition for the CompilerWrapper class.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
void PrintHelp(std::ostream &os) const override
Print the usage of this tool.
void SetDefaults() override
Sets the default values for the tree-panda-gcc tool.
Bambu optimizationss + OPT_compiler_opt_level.
~tree_panda_gcc_parameter() override
Destructor.
Main class for wrapping the frontend compiler.
void PrintGeneralOptionsUsage(std::ostream &os) const
Print the usage of the general common options.
bool isOption(const std::string &name) const
Tests if an option has been stored.
void PrintOutputOptionsUsage(std::ostream &os) const
Print the usage of the output common options.
int argc
The number of input paramters.
std::string relocate_compiler_path(const std::string &path, bool resolve_path=false)
bool ManageDefaultOptions(int next_option, char *optarg_param, bool &exit_success)
Manage default options (common to all tools)
#define OPT_PRINT_FILE_NAME
void PrintProgramName(std::ostream &os) const override
Print the name of the program to be included in the header.
#define PARAMETER_NOTPARSED
Implementation of the wrapper to Gcc for C sources.