1 #ifndef CPPAD_CG_GCC_COMPILER_INCLUDED 2 #define CPPAD_CG_GCC_COMPILER_INCLUDED 31 GccCompiler(
const std::string& gccPath =
"/usr/bin/gcc") :
34 this->_compileFlags.push_back(
"-O2");
35 this->_compileLibFlags.push_back(
"-O2");
36 this->_compileLibFlags.push_back(
"-shared");
37 this->_compileLibFlags.push_back(
"-rdynamic");
49 JobTimer* timer =
nullptr)
override {
51 #if CPPAD_CG_SYSTEM_APPLE 52 std::string linkerName =
"-install_name";
53 #elif CPPAD_CG_SYSTEM_LINUX 54 std::string linkerName =
"-soname";
56 std::string linkerFlags =
"-Wl," + linkerName +
"," + system::filenameFromPath(library);
57 for (
size_t i = 0; i < this->_linkFlags.size(); i++)
58 linkerFlags +=
"," + this->_linkFlags[i];
60 std::vector<std::string> args;
61 args.insert(args.end(), this->_compileLibFlags.begin(), this->_compileLibFlags.end());
62 args.push_back(linkerFlags);
64 args.push_back(library);
65 for (
const std::string& it : this->_ofiles) {
69 if (timer !=
nullptr) {
70 timer->startingJob(
"'" + library +
"'", JobTimer::COMPILING_DYNAMIC_LIBRARY);
71 }
else if (this->_verbose) {
72 std::cout <<
"building library '" << library <<
"'" << std::endl;
77 if (timer !=
nullptr) {
93 const std::string& output,
94 bool posIndepCode)
override {
95 std::vector<std::string> args;
98 args.insert(args.end(), this->_compileFlags.begin(), this->_compileFlags.end());
102 args.push_back(
"-fPIC");
104 args.push_back(
"-o");
105 args.push_back(output);
111 const std::string& output,
112 bool posIndepCode)
override {
113 std::vector<std::string> args;
114 args.push_back(
"-x");
116 args.insert(args.end(), this->_compileFlags.begin(), this->_compileFlags.end());
118 args.push_back(
"-fPIC");
120 args.push_back(
"-c");
121 args.push_back(path);
122 args.push_back(
"-o");
123 args.push_back(output);
void callExecutable(const std::string &executable, const std::vector< std::string > &args, std::string *stdOutErrMessage=nullptr, const std::string *stdInMessage=nullptr)
void compileFile(const std::string &path, const std::string &output, bool posIndepCode) override
void buildDynamic(const std::string &library, JobTimer *timer=nullptr) override
void compileSource(const std::string &source, const std::string &output, bool posIndepCode) override