Skip to content
Snippets Groups Projects
Commit 4f4d9d5b authored by Petr Rockai's avatar Petr Rockai
Browse files

tools: Simplify debug path munging in runtime-cc.

parent 4d6cad1b
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ DIVINE_UNRELAX_WARNINGS ...@@ -15,7 +15,7 @@ DIVINE_UNRELAX_WARNINGS
using namespace divine; using namespace divine;
using namespace brick; using namespace brick;
#define VERSION "3" /* bump this to force rebuilds despite .fp matches */ #define VERSION "4" /* bump this to force rebuilds despite .fp matches */
/* usage: runtime-cc srcdir bindir source.c output.bc [flags] */ /* usage: runtime-cc srcdir bindir source.c output.bc [flags] */
int main( int argc, const char **argv ) int main( int argc, const char **argv )
...@@ -33,7 +33,8 @@ int main( int argc, const char **argv ) ...@@ -33,7 +33,8 @@ int main( int argc, const char **argv )
std::string fpFilename = std::string( argv[ 4 ] ) + ".fp"; std::string fpFilename = std::string( argv[ 4 ] ) + ".fp";
std::string oldFp = fs::readFileOr( fpFilename, {} ); std::string oldFp = fs::readFileOr( fpFilename, {} );
std::string newFp = VERSION ":" + sha2::to_hex( sha2_512( prec ) ); std::string newFp = VERSION ":" + sha2::to_hex( sha2_512( prec ) );
if ( oldFp == newFp && fs::exists( argv[ 4 ] ) ) { if ( oldFp == newFp && fs::exists( argv[ 4 ] ) )
{
fs::touch( argv[ 4 ] ); fs::touch( argv[ 4 ] );
return 0; return 0;
} }
...@@ -41,22 +42,13 @@ int main( int argc, const char **argv ) ...@@ -41,22 +42,13 @@ int main( int argc, const char **argv )
lart::divine::rewriteDebugPaths( *mod, [=]( auto p ) lart::divine::rewriteDebugPaths( *mod, [=]( auto p )
{ {
std::string relpath; auto n = p;
if ( string::startsWith( p, srcDir ) ) if ( string::startsWith( p, srcDir ) )
relpath = p.substr( srcDir.size() ); n = p.substr( srcDir.size() );
else if ( string::startsWith( p, binDir ) ) else if ( string::startsWith( p, binDir ) )
relpath = p.substr( binDir.size() ); n = p.substr( binDir.size() );
if ( string::startsWith( relpath, "/dios" ) ) TRACE( "rewrite", p, "to", n );
relpath = relpath.substr( 5 ); return n;
if ( !relpath.empty() )
{
while ( fs::isPathSeparator( relpath[0] ) )
relpath.erase( relpath.begin() );
auto result = fs::joinPath( rt::directory( relpath ), relpath );
TRACE( "rewrite", p, "to", result );
return result;
}
return p;
} ); } );
brick::llvm::writeModule( mod.get(), argv[4] ); brick::llvm::writeModule( mod.get(), argv[4] );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment