From: Alexandre Oliva Date: Mon, 22 Feb 1999 20:47:30 +0000 (+0000) Subject: * ltmain.in: create on-demand executable as $progdir/$$-$program, X-Git-Tag: release-1-2f~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=231f7fd15f9696e97c48b91e2b847648cab87e09;p=thirdparty%2Flibtool.git * ltmain.in: create on-demand executable as $progdir/$$-$program, and rename it to $progdir/$program only when it's finished, to avoid race conditions. We can still get the program linked multiple times, if multiple instances are started simultaneously and the program does not exist, but they are very unlikely to interfere with each other. There's still a possibility that one process removes the $program another has just created, and doesn't replace it before the other tries to run it, in a system whose `mv' is not atomic, so it will $rm then $mv, but so what? :-) Locking files have been avoided to prevent dead-locks in case they are left over after a reboot or crash. --- diff --git a/ChangeLog b/ChangeLog index a8cfd687e..b130c58c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 1999-02-22 Alexandre Oliva + * ltmain.in: create on-demand executable as $progdir/$$-$program, + and rename it to $progdir/$program only when it's finished, to + avoid race conditions. We can still get the program linked + multiple times, if multiple instances are started simultaneously + and the program does not exist, but they are very unlikely to + interfere with each other. There's still a possibility that one + process removes the $program another has just created, and doesn't + replace it before the other tries to run it, in a system whose + `mv' is not atomic, so it will $rm then $mv, but so what? :-) + Locking files have been avoided to prevent dead-locks in case they + are left over after a reboot or crash. + * TODO: removed ILD, soon to be merged, and added convenience libraries docs diff --git a/ltmain.in b/ltmain.in index d934fc521..fe1dedd82 100644 --- a/ltmain.in +++ b/ltmain.in @@ -2544,7 +2544,7 @@ static const void *lt_preloaded_setup() { fi if test "$shlibpath_overrides_runpath" != yes; then - compile_for_build_command=`echo "X$compile_command" | $Xsed -e "s%@BUILD_LIBDIRS_FLAGS@%$build_libdirs_flags%" -e "s%@BUILD_RPATH@%$build_rpath%" -e "s%@HARDCODE_BUILD_LIBDIRS@%$build_libdirs%" -e 's%@THISDIR@%\$thisdir%g' -e 's%@OUTPUT@%\$progdir/\$program%g'` + compile_for_build_command=`echo "X$compile_command" | $Xsed -e "s%@BUILD_LIBDIRS_FLAGS@%$build_libdirs_flags%" -e "s%@BUILD_RPATH@%$build_rpath%" -e "s%@HARDCODE_BUILD_LIBDIRS@%$build_libdirs%" -e 's%@THISDIR@%\$thisdir%g' -e 's%@OUTPUT@%\$progdir/\$file%g'` fi # Replace the output file specification. @@ -2661,16 +2661,26 @@ else progdir=\"\$thisdir/$objdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ - { newestfile=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ - test \"X\$newestfile\" != \"X\$progdir/\$program\"; }; then - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + $rm \"\$progdir/\$file\"" + + echo >> $output "\ + + # link executable that uses uninstalled libraries + if (cd \"\$thisdir\" && $compile_for_build_command); then : else - $rm \"\$progdir/\$program\" + $rm \"\$progdir/\$file\" + exit 1 fi - # link executable that uses uninstalled libraries - (cd \$thisdir && $compile_for_build_command) || exit 1 + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" fi" fi