1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

305 Commits

Author SHA1 Message Date
Daniel Dunbar
c73565828f Support: Don't remove special files on signals.
- Similar to Path::eraseFromDisk(), we don't want LLVM to remove things like
   /dev/null, even if it has the permission.

llvm-svn: 166105
2012-10-17 16:30:54 +00:00
Benjamin Kramer
f358e32d89 Make backtraces work again with both the configure and cmake build.
llvm-svn: 164817
2012-09-28 10:10:46 +00:00
Sylvestre Ledru
bb07c7bd88 The assumption that /proc/self/exe always exists is incorrect.
For example, under a Linux chroot, /proc/ might not be mounted.
Therefor, we test if this file exist. If it is the case, use it (the current
behavior). Otherwise, we fall back to the detection used by *BSD.

The issue has been reported initially on the Debian bug tracker:
http://bugs.debian.org/674588

llvm-svn: 164676
2012-09-26 08:30:35 +00:00
Eric Christopher
8172c32318 Add an --enable-backtraces option to configure to determine
whether or not we want to print out backtrace information. Useful
for libraries that don't need backtrace information on a crash.

rdar://11844710

llvm-svn: 164426
2012-09-21 23:03:29 +00:00
Andrew Kaylor
960981f691 This patch adds memory support functions which will later be used to implement section-specific protection handling in MCJIT.
llvm-svn: 164249
2012-09-19 20:46:12 +00:00
Chandler Carruth
876a0bce73 Add support for finding cacheflush on OpenBSD/mips64 platforms.
Patch by Brad Smith!

llvm-svn: 163584
2012-09-11 01:17:24 +00:00
NAKAMURA Takumi
1b89cab2ca Whitespace.
llvm-svn: 163289
2012-09-06 03:02:56 +00:00
NAKAMURA Takumi
2c109dd4b6 Unix/Signals.inc: Fix a typo. Thanks to Dani Berg!
llvm-svn: 163288
2012-09-06 03:01:43 +00:00
Michael J. Spencer
b1010e4913 Properly test the LLVM_USE_RVALUE_REFERENCES macro.
llvm-svn: 161978
2012-08-15 19:16:27 +00:00
Michael J. Spencer
c500bff4cd [PathV2] Add mapped_file_region. Implementation for Windows and POSIX.
llvm-svn: 161976
2012-08-15 19:05:47 +00:00
Joerg Sonnenberger
bb0db71d1b stdcxx's cstdio doesn't include stdio.h, but the code using PathV2.inc
includes both. Deal with feof and ferror potentially being macros.

llvm-svn: 161658
2012-08-10 10:56:09 +00:00
Eric Christopher
f5132794cd Add support for the OpenBSD for Bitrig.
Patch by David Hill.

llvm-svn: 161344
2012-08-06 20:52:18 +00:00
Daniel Dunbar
f398977a19 Process: Add sys::Process::FileDescriptorHasColors().
llvm-svn: 160557
2012-07-20 18:29:38 +00:00
Galina Kistanova
8b02fc8d50 Fixed few warnings.
llvm-svn: 160142
2012-07-12 20:45:36 +00:00
Nick Kledzik
d4f7f6f97a Add permissions(), map_file_pages(), and unmap_file_pages() to llvm::sys::fs and add unit test. Unix is implemented. Windows side needs to be implemented.
llvm-svn: 158770
2012-06-20 00:28:54 +00:00
Chandler Carruth
b54e790b4c Don't call 'FilesToRemove[0]' when the vector is empty, even to compute
the address of it. Found by a checking STL implementation used on
a dragonegg builder. Sorry about this one. =/

llvm-svn: 158582
2012-06-16 00:44:07 +00:00
Chandler Carruth
a5e40541e4 Harden the Unix signals code to be more async signal safe.
This is likely only the tip of the ice berg, but this particular bug
caused any double-free on a glibc system to turn into a deadlock! It is
not generally safe to either allocate or release heap memory from within
the signal handler. The 'pop_back()' in RemoveFilesToRemove was deleting
memory and causing the deadlock. What's worse, eraseFromDisk in PathV1
has lots of allocation and deallocation paths. We even passed 'true' in
a place that would have caused the *signal handler* to try to run the
'system' system call and shell out to 'rm -rf'. That was never going to
work...

This patch switches the file removal to use a vector of strings so that
the exact text needed for the 'unlink' system call can be stored there.
It switches the loop to be a boring indexed loop, and directly calls
unlink without looking at the error. It also works quite hard to ensure
that calling 'c_str()' is safe, by ensuring that the non-signal-handling
code path that manipulates the vector always leaves it in a state where
every element has already had 'c_str()' called at least once.

I dunno exactly how overkill this is, but it fixes the
deadlock-on-double free issue, and seems likely to prevent any other
issues from sneaking up.

Sorry for not having a test case, but I *really* don't know how to test
signal handling code easily....

llvm-svn: 158580
2012-06-16 00:09:41 +00:00
Benjamin Kramer
20f186ceb7 Use access(2) instead of stat(2) to check if a file exists.
Apart from being slightly cheaper, this fixes a real bug that hits 32 bit
linux systems. When passing a file larger than 2G to be linked (which isn't
that uncommon with large projects such as WebKit), clang's driver checks
if the file exists but the file size doesn't fit in an off_t and stat(2)
fails with EOVERFLOW. Clang then says that the file doesn't exist instead
of passing it to the linker.

llvm-svn: 157891
2012-06-02 16:28:09 +00:00
Eric Christopher
c2a56d46fc Allow unique_file to take a mode for file permissions, but default
to user only read/write.

Part of rdar://11325849

llvm-svn: 156591
2012-05-11 00:07:44 +00:00
Daniel Dunbar
77eeed20bd [Support] Fix sys::GetRandomNumber() to always use a high quality seed.
llvm-svn: 156414
2012-05-08 20:38:00 +00:00
NAKAMURA Takumi
9ae88f2f80 Unix/Process.inc: Give more useful random seed to srand. Workaround for PR12743.
llvm-svn: 156252
2012-05-06 08:24:24 +00:00
NAKAMURA Takumi
a7d133afee Support/Process: Move llvm::sys::Process::GetRandomNumber() from Process.cpp to Unix/Process.inc.
FIXME: GetRandomNumber() is not implemented in Win32.
llvm-svn: 156251
2012-05-06 08:24:18 +00:00
Daniel Dunbar
d7d85c4a85 [Support] Fix up comments.
llvm-svn: 156239
2012-05-05 16:39:22 +00:00
Daniel Dunbar
6fbad750f3 [Support] Rewrite sys::fs::unique_file to not be stupid with /dev/urandom.
- Just use sys::Process::GetRandomNumber instead of having two poor
   implementations.
 - This is ~70 times (!) faster on my OS X machine.

llvm-svn: 156238
2012-05-05 16:36:24 +00:00
Michael J. Spencer
9ddbe009a4 [Support/Unix] Unconditionally include time.h.
When building LLVM on Linux with libc++ with CMake TIME_WITH_SYS_TIME is
undefined, and HAVE_SYS_TIME_H is defined. This ends up including
sys/time.h but not time.h. Unix/TimeValue.inc requires time.h for asctime_r
and localtime. libstdc++ seems to include time.h anyway, but libc++ does
not.

Fix this by always including time.h

llvm-svn: 155382
2012-04-23 19:00:27 +00:00
Sylvestre Ledru
3e90fea8d3 Conflict with st_dev/st_ino identifiers under Debian GNU/Hurd
The problem is that the struct file_status on UNIX systems has two
members called st_dev and st_ino; those are also members of the
struct stat, and they are reserved identifiers which can also be
provided as #define (and this is the case for st_dev on Hurd).
The solution (attached) is to rename them, for example adding a
"fs_" prefix (= file status) to them.

Patch by Pino Toscano

llvm-svn: 155354
2012-04-23 16:37:23 +00:00
Benjamin Kramer
a72a6005f8 Reapply 'Add reverseColor to raw_ostream'.
To be used in printing unprintable source in clang diagnostics.
Patch by Seth Cantrell, with a minor fix for mingw by me.

llvm-svn: 154805
2012-04-16 08:56:50 +00:00
Argyrios Kyrtzidis
4950ffbb4f Revert r154800 which breaks windows builders.
llvm-svn: 154802
2012-04-16 07:59:39 +00:00
Argyrios Kyrtzidis
3d576f296a Add reverseColor to raw_ostream.
To be used in printing unprintable source in clang diagnostics.
Patch by Seth Cantrell!

llvm-svn: 154800
2012-04-16 07:07:38 +00:00
Sylvestre Ledru
40d3066f8b Fix the build under Debian GNU/Hurd.
Thanks to Pino Toscano for the patch

llvm-svn: 154500
2012-04-11 15:35:36 +00:00
Anton Korobeynikov
6263a4eb87 Fix GetMainExecutable on kFreeBSD.
Patch by Sylvestre Ledru!

llvm-svn: 153435
2012-03-26 12:05:51 +00:00
Jean-Daniel Dupas
818a2a6b7e Fix null to integer conversion warnings.
llvm-svn: 153395
2012-03-24 22:17:50 +00:00
David Blaikie
96c1cf4949 Change default error_code ctor to a 'named ctor' so it's more self-documenting.
Unify default construction of error_code uses on this idiom so that users don't
feel compelled to make static globals for naming convenience. (unfortunately I
couldn't make the original ctor private as some APIs don't return their result,
instead using an out parameter (that makes sense to default construct) - which
is a bit of a pity. I did, however, find/fix some cases of unnecessary default
construction of error_code before I hit the unfixable cases)

llvm-svn: 150197
2012-02-09 19:24:12 +00:00
Chandler Carruth
d328cc2c87 Remove SetWorkingDirectory from the Process interface. Nothing in LLVM
or Clang is using this, and it would be hard to use it correctly given
the thread hostility of the function. Also, it never checked the return
which is rather dangerous with chdir. If someone was in fact using this,
please let me know, as well as what the usecase actually is so that
I can add it back and make it more correct and secure to use. (That
said, it's never going to be "safe" per-se, but we could at least
document the risks...)

llvm-svn: 148211
2012-01-15 08:41:35 +00:00
Argyrios Kyrtzidis
42ff94f069 Disable the crash reporter when running lit tests.
llvm-svn: 147965
2012-01-11 20:53:25 +00:00
Sebastian Pop
53d6e3b9d3 revert r147542 after comments from Joerg Sonnenberger
llvm-svn: 147608
2012-01-05 18:28:46 +00:00
Sebastian Pop
4f82b3a13f use getHostTriple instead of getDefaultTargetTriple in getClosestTargetForJIT
Get back getHostTriple.

For JIT compilation, use the host triple instead of the default
target: this fixes some JIT testcases that used to fail when the
compiler has been configured as a cross compiler.

llvm-svn: 147542
2012-01-04 19:47:22 +00:00
Michael J. Spencer
52d5a254bc Support/Program: Make Change<stream>ToBinary return error_code.
llvm-svn: 146522
2011-12-13 23:16:49 +00:00
Chad Rosier
dc87aebd3c Revert r146363 to allow buildbots to make forward progress.
Original commit message:
Support/FileSystem: Implement canonicalize.

llvm-svn: 146378
2011-12-12 17:58:31 +00:00
Michael J. Spencer
b6d86d4978 Support/FileSystem: Implement bool equivalent(file_status A, file_status B);
llvm-svn: 146364
2011-12-12 06:04:28 +00:00
Michael J. Spencer
fd161c5276 Support/FileSystem: Implement canonicalize.
llvm-svn: 146363
2011-12-12 06:04:01 +00:00
Michael J. Spencer
d85f1f84f3 Support/FileSystem: Implement recursive_directory_iterator and make
directory_iterator preserve InputIterator semantics on copy.

llvm-svn: 146200
2011-12-08 22:50:09 +00:00
Sebastian Pop
f72a853709 rename getHostTriple into getDefaultTargetTriple
llvm-svn: 143502
2011-11-01 21:32:20 +00:00
Sebastian Pop
69b2b86143 rename LLVM_HOSTTRIPLE into LLVM_DEFAULT_TARGET_TRIPLE
llvm-svn: 143501
2011-11-01 21:31:44 +00:00
Eli Friedman
62794425dd Remove a couple unused methods. PR11201.
llvm-svn: 143452
2011-11-01 05:11:01 +00:00
Daniel Dunbar
599366dcae sys::Process: Add a SetWorkingDirectory method.
llvm-svn: 140433
2011-09-23 23:23:36 +00:00
Bob Wilson
817b059c93 Remove the hack to check UNAME_RELEASE when identifying the Darwin version.
This was only needed to locate llvm-gcc's installation directory when clang
falls back to run llvm-gcc for i386 kexts.  As of clang svn r140187, we're
now just searching paths with several different Darwin versions on either
side of the current version, so this is no longer needed.

llvm-svn: 140188
2011-09-20 22:05:56 +00:00
Bill Wendling
7694b6d655 Include limits.h to make sure PATH_MAX is known on Solaris 10.
Patch by Joakim Johansson!

llvm-svn: 139743
2011-09-14 21:49:42 +00:00
Bob Wilson
ee1be855d2 Clarify a comment.
llvm-svn: 137204
2011-08-10 05:02:22 +00:00
Bob Wilson
1ac635c712 Put Darwin-specific code inside an __APPLE__ ifdef.
llvm-svn: 137137
2011-08-09 19:54:32 +00:00
Bob Wilson
a97bb9535d Recognize the UNAME_RELEASE environment variable to match Darwin's uname.
When this variable is set, "uname -r" will return its value instead of the
real OS version.  Make this affect LLVM's triple for consistency.
<rdar://problem/9919167>

llvm-svn: 137111
2011-08-09 05:13:36 +00:00
Nick Lewycky
5194954d20 Don't look at $PWD in GetCurrentDirectory.
llvm-svn: 136477
2011-07-29 18:26:59 +00:00
Nick Lewycky
d9c85b51b5 Teach Path::GetCurrentDirectory to use $PWD, to support users who like to do
screwy things by setting PWD != getcwd(). For example, some developers I know
will use this to control the value in gcc's DW_AT_comp_dir value in debug
output. With this patch, that trick will now work on clang too.

The only other effect of this change is that the static analysis will now
respect $PWD when reporting the directory of the files in its HTML output. I
think that's fine.

llvm-svn: 136459
2011-07-29 04:42:39 +00:00
Argyrios Kyrtzidis
a95f22ea2b Add an optional 'bool makeAbsolute' in llvm::sys::fs::unique_file function.
If true and 'model' parameter is not an absolute path, a temp directory will be prepended.
Make it true by default to match current behaviour.

llvm-svn: 136310
2011-07-28 00:29:20 +00:00
Chad Rosier
bd4367f810 By default mkstemp() creates a temporary file with mode 0600, but the mode
used for open is 0666.  Therefore, add the necessary permission bits for
consistency.
rdar://8621462

llvm-svn: 134430
2011-07-05 18:55:31 +00:00
Andrew Trick
9f867fd2dc Have Program::Wait return -2 for crashed and timeouts instead of embedding
info in the error message. Per Dan's request.

llvm-svn: 131780
2011-05-21 00:56:46 +00:00
Rafael Espindola
d086472933 Don't include information about the build into the information returned by
getHostTriple. This fixes a 32 bit clang running on a 64 bit ubuntu.

llvm-svn: 131463
2011-05-17 15:26:34 +00:00
Andrew Trick
25d4fce092 Bugpoint support for miscompilations that result in a crash.
This change allows bugpoint to pinpoint the "opt" pass and bitcode
segment responsible for a crash caused by miscompilation. At least it
works well for me now, without having to create any custom execution
wrappers.

llvm-svn: 131186
2011-05-11 16:31:24 +00:00
Douglas Gregor
8b6257aba2 Include <pthread.h> before we use pthread_self/pthread_kill
llvm-svn: 130510
2011-04-29 16:12:17 +00:00
Daniel Dunbar
d1ebdf5c43 sys/Host: Change getHostTriple() to return the full Darwin version on OS X.
llvm-svn: 129852
2011-04-20 15:44:33 +00:00
Chris Lattner
0304b82f80 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Andrew Trick
a50ee2e148 revert r128199 until it can be made to work with Frontend/dependency-gen.c.
llvm-svn: 128218
2011-03-24 16:43:37 +00:00
Michael J. Spencer
3314c920a5 Remove all uses of PATH_MAX and MAXPATHLEN from PathV2.
llvm-svn: 128199
2011-03-24 05:23:40 +00:00
Benjamin Kramer
dd8cb156c1 Avoid initializing posix_spawn_file_actions_t if not used.
- glibc falls back to fork+exec if a file actions object is present.
- On BSDs this saves a malloc.

llvm-svn: 127969
2011-03-20 15:52:24 +00:00
Jim Grosbach
b89c5053bf setExecutable() should default to success if there's nothing custom for it.
llvm-svn: 127891
2011-03-18 18:51:03 +00:00
Rafael Espindola
a271db1a12 Add r127409 back now that the windows file was updated.
llvm-svn: 127417
2011-03-10 18:33:29 +00:00
Jakob Stoklund Olesen
891bfab351 Revert r127409 which broke all the Windows bots.
llvm-svn: 127413
2011-03-10 18:01:43 +00:00
Rafael Espindola
b7a2d86ef5 Add support for MemoryBuffers that are not null terminated and add
support for creating buffers that cover only a part of a file.

llvm-svn: 127409
2011-03-10 16:10:30 +00:00
Chris Lattner
9c5c450c56 improve support for OpenBSD, patch by Amit Kulkarni!
llvm-svn: 125943
2011-02-18 17:04:56 +00:00
Douglas Gregor
0044fad1e6 Rip out realpath() support. It's expensive, and often a bad idea, and
I have another way to achieve the same goal.

llvm-svn: 125239
2011-02-09 23:33:15 +00:00
Cameron Zwarich
7538a1fb4a Attempt to fix the build after r125228.
llvm-svn: 125236
2011-02-09 23:02:14 +00:00
Douglas Gregor
75fafed2fd Add llvm::sys::path::canonical(), which provides the canonicalized
name of a path, after resolving symbolic links and eliminating excess
path elements such as "foo/../" and "./".

This routine still needs a Windows implementation, but I don't have a
Windows machine available. Help? Please?

llvm-svn: 125228
2011-02-09 22:11:23 +00:00
Michael J. Spencer
4e4cb59457 Fix rename.
llvm-svn: 123604
2011-01-16 22:18:41 +00:00
Michael J. Spencer
78fc0cacd0 Support/PathV2: Implement get_magic.
llvm-svn: 123544
2011-01-15 18:52:33 +00:00
Michael J. Spencer
6d4a8a7b72 Support/Path: Deprecate PathV1::isDirectory and replace all uses with PathV2::is_directory.
llvm-svn: 123209
2011-01-11 01:21:55 +00:00
Michael J. Spencer
917b043a16 Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists.
llvm-svn: 123151
2011-01-10 02:34:23 +00:00
Michael J. Spencer
e369cc8053 Support/PathV2: Implement directory iteration on POSIX.
llvm-svn: 122879
2011-01-05 16:38:57 +00:00
Michael J. Spencer
26654048d7 Support/PathV1: Deprecate GetRootDirectory.
llvm-svn: 122580
2010-12-27 03:21:41 +00:00
Michael J. Spencer
b3e50a570f Support/PathV1: Deprecate makeAbsolute and remove Unix impl because it annoys people.
llvm-svn: 122553
2010-12-25 20:10:11 +00:00
Nick Lewycky
c85935836b Add missing standard headers. Patch by Joerg Sonnenberger!
llvm-svn: 122193
2010-12-19 20:43:38 +00:00
Michael J. Spencer
3885add959 Support: Remove Alarm. It is unused (via local grep and google code search).
llvm-svn: 121160
2010-12-07 18:41:59 +00:00
Michael J. Spencer
7979bb402f Support/PathV2: Change most functions in the path namespace to return their work
via their return value instead of an out parameter.

llvm-svn: 121149
2010-12-07 17:04:04 +00:00
Michael J. Spencer
a96fe51fa6 Support/PathV2: Remove the error_code return type from all functions in the path
namespace. None of them return anything except for success anyway. These will be
converted to returning their result soon.

llvm-svn: 121109
2010-12-07 03:57:37 +00:00
Michael J. Spencer
2953ba9e66 Support/Unix/PathV2: Return the real error from realpath instead of any error
that close or unlink set.

llvm-svn: 121094
2010-12-07 01:23:39 +00:00
Michael J. Spencer
6874ebd344 Support/Unix/PathV2: Use 0770 instead of 0700 when creating a directory. Also use
the standard macros instead of octal notation.

llvm-svn: 121093
2010-12-07 01:23:29 +00:00
Michael J. Spencer
cfd185355b Support/PathV2: Use SmallVector::clear instead of set_size.
llvm-svn: 121092
2010-12-07 01:23:19 +00:00
Michael J. Spencer
a59a7b3965 Support/PathV2: Clarify and correct documentation.
llvm-svn: 121091
2010-12-07 01:23:08 +00:00
Michael J. Spencer
898af0f235 Support/PathV2: Move current_path from path to fs and fix the Unix implementation.
Unix bug spotted by Dan Gohman.

llvm-svn: 121090
2010-12-07 01:22:31 +00:00
Michael J. Spencer
2cd429339f Support/PathV2: Remove redundant calls to make_error_code.
llvm-svn: 120913
2010-12-04 18:45:32 +00:00
Michael J. Spencer
5a2272dcef Support/FileSystem: Add status implementation.
llvm-svn: 120870
2010-12-04 00:32:40 +00:00
Michael J. Spencer
e1360680ce Support/FileSystem: Add file_size implementation.
llvm-svn: 120867
2010-12-04 00:31:48 +00:00
Michael J. Spencer
6cf89ea23a Support/FileSystem: Add equivalent implementation.
llvm-svn: 120827
2010-12-03 18:49:13 +00:00
Michael J. Spencer
a0346605ae Support/FileSystem: Add resize_file implementation.
llvm-svn: 120819
2010-12-03 17:54:07 +00:00
Michael J. Spencer
ba3176e790 Support/FileSystem: Add rename implementation.
llvm-svn: 120818
2010-12-03 17:53:55 +00:00
Michael J. Spencer
1d9a2b7541 Support/FileSystem: Add remove implementation.
llvm-svn: 120817
2010-12-03 17:53:43 +00:00
Michael J. Spencer
98d9d1509e Support/FileSystem: Add create_symlink implementation.
llvm-svn: 120800
2010-12-03 07:41:25 +00:00
Michael J. Spencer
efc69d250d Support/FileSystem: Add create_hard_link implementation.
llvm-svn: 120792
2010-12-03 05:58:41 +00:00
Michael J. Spencer
96236c93ff Support/FileSystem: Add create_director{y,ies} implementations.
llvm-svn: 120790
2010-12-03 05:42:11 +00:00
Michael J. Spencer
4e1623c715 Support/FileSystem: Add unique_file and exists implementations.
llvm-svn: 120776
2010-12-03 01:21:28 +00:00
Michael J. Spencer
8908ec62e4 Support/FileSystem: Fix copy_file implementation to use toNullTerminatedStringRef
instead of toStringRef. The file system APIs need c strings.

llvm-svn: 120601
2010-12-01 20:37:42 +00:00
Michael J. Spencer
42a5674c7a Support/FileSystem: Add copy_file implementation. Not tests yet because the
file creation APIs aren't implemented.

llvm-svn: 120593
2010-12-01 19:32:01 +00:00
Michael J. Spencer
8ac563a538 Support: Add PathV2 implementation.
llvm-svn: 120329
2010-11-29 22:28:51 +00:00
Charles Davis
e7f14dfdb8 Now to chant the magical incantation that will exorcise the System library
from LLVM forever:

grep -lR "llvm/System" * | grep -v .svn | xargs sed -ie 's#llvm/System#llvm/Support#g'

llvm-svn: 120314
2010-11-29 19:44:50 +00:00
Michael J. Spencer
0d9e3b3a88 Missed a spot.
llvm-svn: 120301
2010-11-29 18:29:55 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00