#include #include DIVINE_RELAX_WARNINGS #include DIVINE_UNRELAX_WARNINGS #include #include #include #include #include using namespace divine; /* usage: runtime-cc srcdir bindir source.c output.bc [flags] */ int main( int argc, const char **argv ) { try { divcc::cc1 clang; std::string srcDir = argv[1], binDir = argv[2]; clang.allow_include_path( srcDir ); clang.allow_include_path( binDir ); std::vector< std::string > opts; std::copy( argv + 5, argv + argc, std::back_inserter( opts ) ); std::string depfile; auto end = std::remove_if( opts.begin(), opts.end(), []( auto s ) { return brq::starts_with( s, "-M" ); } ); for ( auto i = end; i != opts.end(); ++i ) if ( brq::starts_with( *i, "-MF" ) ) depfile = i->substr( 3 ); opts.erase( end, opts.end() ); auto mod = clang.compile( argv[3], opts, depfile ); TRACE( "bindir =", binDir, "srcdir =", srcDir ); lart::divine::rewriteDebugPaths( *mod, [=]( auto p ) { auto n = p; if ( brq::starts_with( p, srcDir ) ) n = p.substr( srcDir.size() ); if ( brq::starts_with( p, binDir ) ) n = p.substr( binDir.size() ); TRACE( "rewrite", p, "to", n ); return n; } ); brq::llvm_write( mod.get(), argv[4] ); return 0; } catch ( divcc::compile_error &err ) { std::cerr << err.what() << std::endl; return 1; } }