From 6beda1bcee4396ceced99b8a8c5627940f507ace Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 20 Dec 2020 23:09:31 +0000 Subject: internals: error tracing: record the not-found path upon ENOENT as needed. --- src/driver/slbt_driver_ctx.c | 15 +++++++-- src/helper/slbt_archive_import.c | 6 ++-- src/helper/slbt_copy_file.c | 3 +- src/internal/slibtool_errinfo_impl.c | 2 +- src/internal/slibtool_errinfo_impl.h | 4 +-- src/internal/slibtool_lconf_impl.c | 8 ++--- src/internal/slibtool_libmeta_impl.c | 8 ++--- src/internal/slibtool_objmeta_impl.c | 8 ++--- src/internal/slibtool_symlink_impl.c | 4 +-- src/logic/slbt_exec_compile.c | 10 +++--- src/logic/slbt_exec_execute.c | 2 +- src/logic/slbt_exec_install.c | 12 +++---- src/logic/slbt_exec_link.c | 64 ++++++++++++++++++++---------------- src/logic/slbt_exec_uninstall.c | 6 ++-- src/output/slbt_output_config.c | 22 ++++++------- src/output/slbt_output_exec.c | 12 +++---- src/output/slbt_output_features.c | 6 ++-- 17 files changed, 105 insertions(+), 87 deletions(-) diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index b105c2b..4812076 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -1755,6 +1755,17 @@ int slbt_get_driver_ctx( static void slbt_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx) { + struct slbt_error_info ** perr; + struct slbt_error_info * erri; + + for (perr=ictx->ctx.errinfp; *perr; perr++) { + erri = *perr; + + if (erri->eany && (erri->esyscode == ENOENT)) + free(erri->eany); + } + + if (ictx->ctx.libname) free(ictx->ctx.libname); @@ -1807,11 +1818,11 @@ int slbt_set_alternate_host( slbt_free_host_params(&ictx->ctx.ahost); if (!(ictx->ctx.ahost.host = strdup(host))) - return SLBT_SYSTEM_ERROR(ctx); + return SLBT_SYSTEM_ERROR(ctx,0); if (!(ictx->ctx.ahost.flavor = strdup(flavor))) { slbt_free_host_params(&ictx->ctx.ahost); - return SLBT_SYSTEM_ERROR(ctx); + return SLBT_SYSTEM_ERROR(ctx,0); } ictx->ctx.cctx.ahost.host = ictx->ctx.ahost.host; diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c index 84bef92..ae8821b 100644 --- a/src/helper/slbt_archive_import.c +++ b/src/helper/slbt_archive_import.c @@ -103,12 +103,12 @@ int slbt_archive_import( /* fork */ if (pipe(fd)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if ((pid = fork()) < 0) { close(fd[0]); close(fd[1]); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } /* child */ @@ -131,7 +131,7 @@ int slbt_archive_import( if (slbt_dprintf(fd[1],fmt,dst,src) < 0) { close(fd[1]); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } close(fd[1]); diff --git a/src/helper/slbt_copy_file.c b/src/helper/slbt_copy_file.c index c74ffcc..e9abee5 100644 --- a/src/helper/slbt_copy_file.c +++ b/src/helper/slbt_copy_file.c @@ -1,3 +1,4 @@ + /*******************************************************************/ /* slibtool: a skinny libtool implementation, written in C */ /* Copyright (C) 2016--2018 Z. Gilboa */ @@ -55,7 +56,7 @@ int slbt_copy_file( /* dlltool spawn */ ret = ((slbt_spawn(ectx,true) < 0) || ectx->exitcode) - ? SLBT_SYSTEM_ERROR(dctx) : 0; + ? SLBT_SYSTEM_ERROR(dctx,0) : 0; ectx->argv = oargv; ectx->program = oprogram; diff --git a/src/internal/slibtool_errinfo_impl.c b/src/internal/slibtool_errinfo_impl.c index 472c818..84f019e 100644 --- a/src/internal/slibtool_errinfo_impl.c +++ b/src/internal/slibtool_errinfo_impl.c @@ -34,7 +34,7 @@ int slbt_record_error( erri->efunction = efunction; erri->eline = eline; erri->eflags = eflags; - erri->eany = eany; + erri->eany = (eany && (esyscode == ENOENT)) ? strdup(eany) : eany; ictx->errinfp++; diff --git a/src/internal/slibtool_errinfo_impl.h b/src/internal/slibtool_errinfo_impl.h index a1d3b61..1c3fb9f 100644 --- a/src/internal/slibtool_errinfo_impl.h +++ b/src/internal/slibtool_errinfo_impl.h @@ -19,7 +19,7 @@ int slbt_record_error( unsigned eflags, void * eany); -#define SLBT_SYSTEM_ERROR(dctx) \ +#define SLBT_SYSTEM_ERROR(dctx,eany) \ slbt_record_error( \ dctx, \ errno, \ @@ -27,7 +27,7 @@ int slbt_record_error( __func__, \ __LINE__, \ SLBT_ERROR_TOP_LEVEL, \ - 0) + (void *)eany) #define SLBT_BUFFER_ERROR(dctx) \ slbt_record_error( \ diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index 6b55c9f..ad335f1 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -51,7 +51,7 @@ static int slbt_lconf_open( : fdlconf; if (fstatat(fdlconfdir,".",&stcwd,0) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); lconf = lconf ? lconf : "libtool"; fdlconf = openat(fdlconfdir,lconf,O_RDONLY,0); @@ -62,11 +62,11 @@ static int slbt_lconf_open( slbt_lconf_close(fdcwd,fdlconfdir); if (fdparent < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (fstat(fdparent,&stparent) < 0) { close(fdparent); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } if (stparent.st_dev != stcwd.st_dev) { @@ -115,7 +115,7 @@ int slbt_get_lconf_flags( /* map relative libtool script */ if (fstat(fdlconf,&st) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); addr = mmap( 0,st.st_size, diff --git a/src/internal/slibtool_libmeta_impl.c b/src/internal/slibtool_libmeta_impl.c index 18984bd..31d060d 100644 --- a/src/internal/slibtool_libmeta_impl.c +++ b/src/internal/slibtool_libmeta_impl.c @@ -41,7 +41,7 @@ static int slbt_create_default_library_wrapper( dctx->cctx->output, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,dctx->cctx->output); /* version info */ current = 0; @@ -124,7 +124,7 @@ static int slbt_create_default_library_wrapper( close(fdout); - return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx,0) : 0; } static int slbt_create_compatible_library_wrapper( @@ -153,7 +153,7 @@ static int slbt_create_compatible_library_wrapper( dctx->cctx->output, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,dctx->cctx->output); /* version info */ current = 0; @@ -263,7 +263,7 @@ static int slbt_create_compatible_library_wrapper( close(fdout); - return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx,0) : 0; } int slbt_create_library_wrapper( diff --git a/src/internal/slibtool_objmeta_impl.c b/src/internal/slibtool_objmeta_impl.c index b38cf75..f1a33d0 100644 --- a/src/internal/slibtool_objmeta_impl.c +++ b/src/internal/slibtool_objmeta_impl.c @@ -25,7 +25,7 @@ static int slbt_create_default_object_wrapper( ectx->ltobjname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,ectx->ltobjname); verinfo = slbt_source_version(); @@ -50,7 +50,7 @@ static int slbt_create_default_object_wrapper( close(fdout); - return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx,0) : 0; } static int slbt_create_compatible_object_wrapper( @@ -66,7 +66,7 @@ static int slbt_create_compatible_object_wrapper( ectx->ltobjname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx, ectx->ltobjname); verinfo = slbt_source_version(); @@ -98,7 +98,7 @@ static int slbt_create_compatible_object_wrapper( close(fdout); - return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx,0) : 0; } int slbt_create_object_wrapper( diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c index 5ce9158..dd91d5e 100644 --- a/src/internal/slibtool_symlink_impl.c +++ b/src/internal/slibtool_symlink_impl.c @@ -101,10 +101,10 @@ int slbt_create_symlink( /* create symlink */ if (symlink(atarget,tmplnk)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,tmplnk); return rename(tmplnk,lnkname) - ? SLBT_SYSTEM_ERROR(dctx) + ? SLBT_SYSTEM_ERROR(dctx,lnkname) : 0; } diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c index 3ccea3c..dca6e1e 100644 --- a/src/logic/slbt_exec_compile.c +++ b/src/logic/slbt_exec_compile.c @@ -27,7 +27,7 @@ static int slbt_exec_compile_remove_file( if (!(unlink(target)) || (errno == ENOENT)) return 0; - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } static int slbt_exec_compile_finalize_argument_vector( @@ -59,7 +59,7 @@ static int slbt_exec_compile_finalize_argument_vector( sargvbuf = 0; } else if (!(sargvbuf = calloc(parg-base+1,sizeof(char *)))) { - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } else { aargv = sargvbuf; @@ -156,7 +156,7 @@ int slbt_exec_compile( if (cctx->drvflags & SLBT_DRIVER_SHARED) if (slbt_mkdir(dctx,ectx->ldirname)) { slbt_free_exec_ctx(actx); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,ectx->ldirname); } /* compile mode */ @@ -200,7 +200,7 @@ int slbt_exec_compile( if (((ret = slbt_spawn(ectx,true)) < 0) || ectx->exitcode) { slbt_free_exec_ctx(actx); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } if (cctx->drvflags & SLBT_DRIVER_STATIC) @@ -231,7 +231,7 @@ int slbt_exec_compile( if (((ret = slbt_spawn(ectx,true)) < 0) || ectx->exitcode) { slbt_free_exec_ctx(actx); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } diff --git a/src/logic/slbt_exec_execute.c b/src/logic/slbt_exec_execute.c index 11718e9..f284512 100644 --- a/src/logic/slbt_exec_execute.c +++ b/src/logic/slbt_exec_execute.c @@ -88,5 +88,5 @@ int slbt_exec_execute( execvp(ectx->cargv[0],ectx->argv); slbt_free_exec_ctx(actx); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c index 0ab33a5..b8d3ee9 100644 --- a/src/logic/slbt_exec_install.c +++ b/src/logic/slbt_exec_install.c @@ -172,7 +172,7 @@ static int slbt_exec_install_import_libraries( /* libfoo.so.def.{flavor} */ if (slbt_readlink(hostlnk,hosttag,sizeof(hosttag))) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,hostlnk); /* host/flabor */ if (!(host = strrchr(hosttag,'.'))) @@ -258,12 +258,12 @@ static int slbt_exec_install_library_wrapper( /* fddst (libfoo.la.slibtool.install, build directory) */ if ((fddst = openat(fdcwd,clainame,O_RDWR|O_CREAT|O_TRUNC,0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,clainame); /* mapinfo (libfoo.la, build directory) */ if (!(mapinfo = slbt_map_file(fdcwd,entry->arg,SLBT_MAP_INPUT))) { close(fddst); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,entry->arg); } /* srcline */ @@ -278,7 +278,7 @@ static int slbt_exec_install_library_wrapper( if (!srcline) { close(fddst); slbt_unmap_file(mapinfo); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } /* copy config, installed=no --> installed=yes */ @@ -296,7 +296,7 @@ static int slbt_exec_install_library_wrapper( if (slbt_dprintf(fddst,"%s",dstline) < 0) { close(fddst); slbt_unmap_file(mapinfo); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } @@ -433,7 +433,7 @@ static int slbt_exec_install_entry( /* -avoid-version? */ if (stat(slnkname,&st)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,slnkname); /* dstfile */ if ((size_t)snprintf(dstfile,sizeof(dstfile),"%s/%s", diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index c07a173..2ffb6ad 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -122,7 +122,7 @@ static int slbt_get_deps_meta( /* mapinfo */ if (!(mapinfo = slbt_map_file(fdcwd,depfile,SLBT_MAP_INPUT))) return (fexternal && (errno == ENOENT)) - ? 0 : SLBT_SYSTEM_ERROR(dctx); + ? 0 : SLBT_SYSTEM_ERROR(dctx,depfile); /* copied length */ depsmeta->infolen += mapinfo->size; @@ -353,7 +353,7 @@ static int slbt_exec_link_adjust_argument_vector( argc++; if (!(depsmeta->args = calloc(1,depsmeta->infolen))) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); argc *= 3; argc += depsmeta->depscnt; @@ -361,7 +361,7 @@ static int slbt_exec_link_adjust_argument_vector( if (!(depsmeta->altv = calloc(argc,sizeof(char *)))) return slbt_exec_link_exit( depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,0)); fdcwd = slbt_driver_fdcwd(dctx); @@ -448,7 +448,7 @@ static int slbt_exec_link_adjust_argument_vector( sizeof(rpathdir))) return slbt_exec_link_exit( depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,rpathlnk)); sprintf(darg,"-Wl,%s",rpathdir); *aarg++ = "-Wl,-rpath"; @@ -483,7 +483,7 @@ static int slbt_exec_link_adjust_argument_vector( cwd,arg) < 0) return slbt_exec_link_exit( depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,0)); } *aarg++ = *carg++; @@ -506,7 +506,7 @@ static int slbt_exec_link_adjust_argument_vector( SLBT_MAP_INPUT))) return slbt_exec_link_exit( depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,dpath)); if (!(strncmp(lib,".libs/",6))) { *aarg++ = "-L.libs"; @@ -607,7 +607,7 @@ static int slbt_exec_link_finalize_argument_vector( sargvbuf = 0; } else if (!(sargvbuf = calloc(2*(parg-base+1),sizeof(char *)))) { - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } else { aargv = &sargvbuf[0]; @@ -772,7 +772,7 @@ static int slbt_exec_link_remove_file( if (!(unlink(target)) || (errno == ENOENT)) return 0; - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } static int slbt_exec_link_create_dep_file( @@ -815,7 +815,7 @@ static int slbt_exec_link_create_dep_file( /* deps */ if ((deps = openat(fdcwd,depfile,O_RDWR|O_CREAT|O_TRUNC,0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,depfile); /* iterate */ for (parg=altv; *parg; parg++) { @@ -880,19 +880,19 @@ static int slbt_exec_link_create_dep_file( if (fdyndep && (base > *parg) && (ectx->ldirdepth >= 0)) { if (slbt_dprintf(deps,"-L") < 0) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } for (ldepth=ectx->ldirdepth; ldepth; ldepth--) { if (slbt_dprintf(deps,"../") < 0) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } if (slbt_dprintf(deps,"%s/.libs\n",reladir) < 0) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } @@ -904,7 +904,7 @@ static int slbt_exec_link_create_dep_file( if (slbt_dprintf(deps,"-l%s\n",mark) < 0) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } *popt = '.'; @@ -940,7 +940,7 @@ static int slbt_exec_link_create_dep_file( if (!mapinfo && (errno != ENOENT)) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } @@ -959,7 +959,7 @@ static int slbt_exec_link_create_dep_file( if (!mapinfo) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,depfile); } } @@ -986,7 +986,7 @@ static int slbt_exec_link_create_dep_file( if (ret < 0) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } @@ -996,12 +996,12 @@ static int slbt_exec_link_create_dep_file( if (plib && (slbt_dprintf(deps,"-l%s\n",plib) < 0)) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } if (path && (slbt_dprintf(deps,"-L%s\n",path) < 0)) { close(deps); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } } @@ -1136,7 +1136,7 @@ static int slbt_exec_link_create_noop_symlink( return 0; } - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,arfilename); } static int slbt_exec_link_create_archive( @@ -1244,7 +1244,7 @@ static int slbt_exec_link_create_archive( return SLBT_NESTED_ERROR(dctx); if (symlink(arfile,arlink)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,arlink); } return 0; @@ -1411,12 +1411,12 @@ static int slbt_exec_link_create_library( return SLBT_NESTED_ERROR(dctx); if (symlink(dctx->cctx->host.ldrpath,ectx->rpathfilename)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,ectx->rpathfilename); } /* cwd */ if (!getcwd(cwd,sizeof(cwd))) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); /* .libs/libfoo.so --> -L.libs -lfoo */ if (slbt_exec_link_adjust_argument_vector( @@ -1467,6 +1467,7 @@ static int slbt_exec_link_create_executable( bool fpic; const struct slbt_source_version * verinfo; struct slbt_deps_meta depsmeta = {0,0,0,0}; + struct stat st; /* initial state */ slbt_reset_arguments(ectx); @@ -1506,7 +1507,7 @@ static int slbt_exec_link_create_executable( return SLBT_BUFFER_ERROR(dctx); if ((fdwrap = openat(fdcwd,wrapper,O_RDWR|O_CREAT|O_TRUNC,0644)) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,wrapper); slbt_exec_set_fdwrapper(ectx,fdwrap); @@ -1533,7 +1534,7 @@ static int slbt_exec_link_create_executable( verinfo->major,verinfo->minor,verinfo->revision, verinfo->commit, dctx->cctx->settings.ldpathenv) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); /* output */ if ((size_t)snprintf(output,sizeof(output),"%s", @@ -1550,7 +1551,7 @@ static int slbt_exec_link_create_executable( /* cwd */ if (!getcwd(cwd,sizeof(cwd))) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); /* .libs/libfoo.so --> -L.libs -lfoo */ if (slbt_exec_link_adjust_argument_vector( @@ -1593,7 +1594,7 @@ static int slbt_exec_link_create_executable( fabspath ? &exefilename[1] : exefilename) < 0) return slbt_exec_link_exit( &depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,0)); /* sigh */ if (slbt_exec_link_finalize_argument_vector(dctx,ectx)) @@ -1623,15 +1624,20 @@ static int slbt_exec_link_create_executable( &depsmeta, SLBT_NESTED_ERROR(dctx)); + if (stat(wrapper,&st)) + return slbt_exec_link_exit( + &depsmeta, + SLBT_SYSTEM_ERROR(dctx,wrapper)); + if (rename(wrapper,dctx->cctx->output)) return slbt_exec_link_exit( &depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,dctx->cctx->output)); if (chmod(dctx->cctx->output,0755)) return slbt_exec_link_exit( &depsmeta, - SLBT_SYSTEM_ERROR(dctx)); + SLBT_SYSTEM_ERROR(dctx,dctx->cctx->output)); return slbt_exec_link_exit(&depsmeta,0); } @@ -1760,7 +1766,7 @@ int slbt_exec_link( /* .libs directory */ if (slbt_mkdir(dctx,ectx->ldirname)) { slbt_free_exec_ctx(actx); - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,ectx->ldirname); } /* non-pic libfoo.a */ diff --git a/src/logic/slbt_exec_uninstall.c b/src/logic/slbt_exec_uninstall.c index 182bc8d..c0aa87f 100644 --- a/src/logic/slbt_exec_uninstall.c +++ b/src/logic/slbt_exec_uninstall.c @@ -82,12 +82,12 @@ static int slbt_exec_uninstall_fs_entry( return 0; else - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,path); } /* remove file or symlink entry */ if (unlink(path)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,path); /* remove empty containing directory? */ if (flags & SLBT_UNINSTALL_RMDIR) { @@ -100,7 +100,7 @@ static int slbt_exec_uninstall_fs_entry( *slash = 0; if (rmdir(dpath)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,dpath); } return 0; diff --git a/src/output/slbt_output_config.c b/src/output/slbt_output_config.c index 934da61..cac0df9 100644 --- a/src/output/slbt_output_config.c +++ b/src/output/slbt_output_config.c @@ -78,37 +78,37 @@ int slbt_output_config(const struct slbt_driver_ctx * dctx) midwidth &= (~(SLBT_TAB_WIDTH-1)); if (slbt_output_config_line(fdout,"key","value","annotation",midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"---","-----","----------",midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"compiler",cctx->cargv[0],"",midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"target",cctx->target,"",midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"host",cctx->host.host,cctx->cfgmeta.host,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"flavor",cctx->host.flavor,cctx->cfgmeta.flavor,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"ar",cctx->host.ar,cctx->cfgmeta.ar,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"ranlib",cctx->host.ranlib,cctx->cfgmeta.ranlib,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"windres",cctx->host.windres,cctx->cfgmeta.windres,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"dlltool",cctx->host.dlltool,cctx->cfgmeta.dlltool,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_output_config_line(fdout,"mdso",cctx->host.mdso,cctx->cfgmeta.mdso,midwidth)) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); return 0; } diff --git a/src/output/slbt_output_exec.c b/src/output/slbt_output_exec.c index f1d06ed..6adceb6 100644 --- a/src/output/slbt_output_exec.c +++ b/src/output/slbt_output_exec.c @@ -38,7 +38,7 @@ static int slbt_output_exec_annotated( aclr_bold,aclr_magenta, dctx->program,aclr_reset, aclr_bold,aclr_green,step,aclr_reset) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); for (parg=ectx->argv; *parg; parg++) { if ((parg == ectx->lout[0]) || (parg == ectx->mout[0])) { @@ -56,12 +56,12 @@ static int slbt_output_exec_annotated( aclr_set,aclr_color, *parg, aclr_unset) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); } if (slbt_dprintf(fdout,"\n") < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); return 0; } @@ -77,14 +77,14 @@ static int slbt_output_exec_plain( fdout = slbt_driver_fdout(dctx); if (slbt_dprintf(fdout,"%s: %s:",dctx->program,step) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); for (parg=ectx->argv; *parg; parg++) if (slbt_dprintf(fdout," %s",*parg) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_dprintf(fdout,"\n") < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); return 0; } diff --git a/src/output/slbt_output_features.c b/src/output/slbt_output_features.c index 3a3b828..a6276da 100644 --- a/src/output/slbt_output_features.c +++ b/src/output/slbt_output_features.c @@ -31,13 +31,13 @@ int slbt_output_features(const struct slbt_driver_ctx * dctx) ? disable : enable; if (slbt_dprintf(fdout,"host: %s\n",dctx->cctx->host.host) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_dprintf(fdout,"%s shared libraries\n",shared_option) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); if (slbt_dprintf(fdout,"%s static libraries\n",static_option) < 0) - return SLBT_SYSTEM_ERROR(dctx); + return SLBT_SYSTEM_ERROR(dctx,0); return 0; } -- cgit v1.2.3