summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Filesystem.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fail early if an output file is not writableRui Ueyama2019-03-111-102/+0
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=36478 Differential Revision: https://reviews.llvm.org/D43664 llvm-svn: 355834
* Revert "Revert "[lld] Fix elf::unlinkAsync detached thread""Nick Desaulniers2019-02-141-2/+19
| | | | | | This reverts commit 9934f2ff02dba9fdabe6e27a83f9f95388bf4132. llvm-svn: 354081
* Revert "[lld] Fix elf::unlinkAsync detached thread"Nick Desaulniers2019-02-141-19/+2
| | | | | | This reverts commit 2694810153cf992823eb45253d26b8567424438f. llvm-svn: 354080
* [lld] Fix elf::unlinkAsync detached threadVitaly Buka2019-02-141-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: So this patch just make sure that the thread is at least stated before we return from main. If we just detach then the thread may be actually be stated just after the process returned from main and it's calling atexit handers. Then the thread may try to create own function static variable and it will add new at exit handlers confusing libc. GLIBC before 2.27 had race in that case which corrupted atexit handlers list. Support for this use-case for other implementation is also unclear, so we can try just avoid that. PR40162 Reviewers: ruiu, espindola Subscribers: emaste, arichardson, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58246 llvm-svn: 354078
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* s/LLVM_ON_WIN32/_WIN32/, lldNico Weber2018-04-101-1/+1
| | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. llvm-svn: 329696
* Don't use llvm/Config/config.h.Rafael Espindola2017-11-171-2/+2
| | | | | | | | It is private to llvm. Instead use llvm/Config/llvm-config.h and check LLVM_ON_UNIX. That is the same guard that clang uses before including unistd.h. llvm-svn: 318558
* Handle "-" in tryCreateFile.Rafael Espindola2017-11-081-0/+2
| | | | | | | Otherwise we would fail with -M if the we didn't have write permissions to the current directory. llvm-svn: 317740
* Remove a given file even if openFileForRead fails.Rui Ueyama2017-11-081-4/+3
| | | | | | | | | | I think the constract of this function is to remove a file in some way, whether in background or in foreground. This patch makes sure that it removes a given file. Differential Revision: https://reviews.llvm.org/D39778 llvm-svn: 317663
* Update for llvm change.Rafael Espindola2017-11-081-1/+1
| | | | llvm-svn: 317650
* Fix unused variable error.Rafael Espindola2017-11-071-1/+1
| | | | llvm-svn: 317637
* Use std::thread directly.Rafael Espindola2017-11-071-1/+2
| | | | | | Now that this code is posix only we don't need to use runBackground. llvm-svn: 317632
* Simplify unlinkAsync.Rafael Espindola2017-11-071-13/+20
| | | | | | | | | | | It used to rename the file before removing it in a background thread. A simpler way to delay the removal is simply to open the file. Since this is a posix specific issue, simplify the windows implementation. llvm-svn: 317631
* Use Path instead of Config->OutputFile. NFC.Rafael Espindola2017-11-071-2/+2
| | | | | | | | This function is always called with Config->OutputFile. That is not obvious from reading the function. It should always use Path or take no argument and always use Config->OutputFile. llvm-svn: 317536
* [lld] Move Threads to CommonBob Haarman2017-10-131-2/+2
| | | | | | | | | | | | | | | | Summary: This will allow using the functionality from other linkers. It is also a prerequisite for sharing the error logging code. Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38822 llvm-svn: 315725
* Wait for all threads to terminate before exitting.Rui Ueyama2017-10-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | I think it is not defined what would happen to detached threads when the main thread tries to exit. That means it was not guaranteed that unlinkAsync correctly removes a temporary file. It was also reported that this unlinkAsync caused a crash on Windows. This patch adds a few new functions so that the main thread always waits for non-main threads before exitting. I don't actually like the new two functions, runBackground and waitForBackgroundThreads, because it looks like it is a bit overdesigned. After all, what we are doing with these functions is to just remove a file. An alternative would be to do fork(2) and make the child process remove a file asynchronously. However, it has its own problems. Correctly forking and reclaiming a resource using waitpid(2) is not doable unless we know our process-wide settings (such as signal mask), but we can't make any assumption on it when lld is embedded to other process. So I chose to stick with threads instead of multi-processes. Differential Revision: https://reviews.llvm.org/D38571 llvm-svn: 315033
* ELF: Only unlink regular filesTom Stellard2017-07-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If the output file is a character file (e.g. /dev/null) unlinking it could potentially destabilize the user's system. For example, unlinking causes `lld %input -o /dev/null` to replace /dev/null with a regular file, which will lead to unexpected behavior in other programs that read from /dev/null, and worse than expected peformance for programs that write to /dev/null. This makes it possible to run the test-release.sh script as root. Prior to this patch, the ELF/basic.s test would replace /dev/null with a regular file, which would cause crashes in llvm test-suite programs that piped /dev/null to stdin. For example, if you run the test-relase.sh script as root, Reviewers: ruiu Reviewed By: ruiu Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D34917 llvm-svn: 307092
* Make LLD work even if the current directory is not writable.Rui Ueyama2017-04-261-0/+2
| | | | llvm-svn: 301423
* Move code to emit error messages from Filesystem.cpp to Driver.cpp.Rui Ueyama2017-04-261-10/+5
| | | | | | | | isFileWritable() checked if a file is writable and then emitted an error message if it is not writable. So it did more than the name says. This patch moves error() calls to Driver. llvm-svn: 301422
* [ELF] Fail the link early if the map file path is invalidJames Henderson2017-04-041-2/+2
| | | | | | | | | | | | | As with the changes made in r297645, we do not want a potentially long link to be run, if it will ultimately fail because the map file is not writable. This change reuses the same functionality as the output file path check. See https://reviews.llvm.org/D30449 for further justification and explanations. Reviewers: ruiu Differential Revision: https://reviews.llvm.org/D31603 llvm-svn: 299420
* Move a few functions to a new file Filesystem.{cpp,h}.Rui Ueyama2017-03-241-0/+79
llvm-svn: 298667
OpenPOWER on IntegriCloud