Commit Graph

240 Commits

Author SHA1 Message Date
Peter Collingbourne
bef2236283 Introduce llvm::sys::path::home_directory.
This will be used by the line editor library to derive a default path to
the history file.

Differential Revision: http://llvm-reviews.chandlerc.com/D2199

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200594 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31 23:46:06 +00:00
Mark Seaborn
01df6842c1 Fix the "#ifndef HAVE_SYS_WAIT_H" code path in Program.inc to compile
Without this fix, WaitResult is not defined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200259 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-27 22:53:07 +00:00
Hans Wennborg
837d6ed3ea Make sys::ThreadLocal<> zero-initialized on non-thread builds (PR18205)
According to the docs, ThreadLocal<>::get() should return NULL
if no object has been set. This patch makes that the case also for non-thread
builds and adds a very basic unit test to check it.

(This was causing PR18205 because PrettyStackTraceHead didn't get zero-
initialized and we'd crash trying to read past the end of that list. We didn't
notice this so much on Linux since we'd crash after printing all the entries,
but on Mac we print into a SmallString, and would crash before printing that.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197718 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 20:32:44 +00:00
Alp Toker
00a9489ff3 Build fix for Android NDK which has neither futimes nor futimens
Based on a patch by Neil Henning!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197045 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-11 15:42:33 +00:00
Sylvestre Ledru
1a803295d0 Improve the detection of the path
Summary:
When clang is used under GNU/Linux in a chroot without /proc mount, it falls
back on the BSD method. However, since the buf variable is used twice
and fails with snprintf to produce the correct path.

When called as relatived (ie ./clang), it was failing with:
 "" -cc1 [...] -x c++ x.cc
error: unable to execute command: Executable "" doesn't exist!


I also took the opportunity to simply the code (the first arg of test_dir
was useless).

Reviewers: rafael

Reviewed By: rafael

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2361

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196791 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09 16:27:00 +00:00
Alp Toker
087ab613f4 Correct word hyphenations
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities and contractions in nearby lines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196471 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 05:44:44 +00:00
Rafael Espindola
90f9b8a7bc Rules adjustments in order to build on DragonFly BSD.
Patch by Robin Hahling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193750 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 14:35:00 +00:00
Rafael Espindola
88fc7015ce Fix build on Solaris 11.
Patch by Vladimir Voskresensky. The erros were:

Path.inc:274:3: error: ‘Dl_info’ was not declared in this scope
...

and

usr/include/spawn.h:52:14: error: expected ‘,’ or ‘...’ before ‘argv’

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192185 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-08 16:12:58 +00:00
David Majnemer
6a971bb8f5 Revert "Revert "Windows: Add support for unicode command lines""
This reverts commit r192070 which reverted r192069, I forgot to
regenerate the configure scripts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192079 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-07 01:00:07 +00:00
David Majnemer
b262556c45 Revert "Windows: Add support for unicode command lines"
This is causing MinGW bots to fail.
This reverts commit r192069.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192070 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-06 20:44:34 +00:00
David Majnemer
5a1a1856a4 Windows: Add support for unicode command lines
Summary:
The MSVCRT deliberately sends main() code-page specific characters.
This isn't too useful to LLVM as we end up converting the arguments to
UTF-16 and subsequently attempt to use the result as, for example, a
file name.  Instead, we need to have the ability to access the Unicode
command line and transform it to UTF-8.

This has the distinct advantage over using the MSVC-specific wmain()
function as our entry point because:
 - It doesn't work on cygwin.
 - It only work on MinGW with caveats and only then on certain versions.
 - We get to keep our entry point as main(). :)

N.B.  This patch includes fixes to other parts of lib/Support/Windows
s.t. we would be able to take advantage of getting the Unicode paths.
E.G.  clang spawning clang -cc1 would want to give it Unicode arguments.

Reviewers: aaron.ballman, Bigcheese, rnk, ruiu

Reviewed By: rnk

CC: llvm-commits, ygao

Differential Revision: http://llvm-reviews.chandlerc.com/D1834

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192069 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-06 20:25:49 +00:00
Tareq A. Siraj
c269c4f505 Add non-blocking Wait() for launched processes
- New ProcessInfo class to encapsulate information about child processes.
- Generalized the Wait() to support non-blocking wait on child processes.
- ExecuteNoWait() now returns a ProcessInfo object with information about
  the launched child. Users will be able to use this object to
  perform non-blocking wait.
- ExecuteNoWait() now accepts an ExecutionFailed param that tells if execution
  failed or not.

These changes will allow users to implement basic process parallel
tools.

Differential Revision: http://llvm-reviews.chandlerc.com/D1728


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191763 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 14:28:18 +00:00
Nico Rieck
44a61bde15 Support ANSI escape code on Windows
In some cases (e.g. when a build system pipes stderr) the Windows console
API cannot be used to color output. For these, provide a way to switch to
ANSI escape codes. This is required for Clang's -fansi-escape-codes option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190460 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:36:48 +00:00
Rui Ueyama
f42d4247ae Add getenv() wrapper that works on multibyte environment variable.
On Windows, character encoding of multibyte environment variable varies
depending on settings. The only reliable way to handle it I think is to use
GetEnvironmentVariableW().

GetEnvironmentVariableW() works on wchar_t string, which is on Windows UTF16
string. That's not ideal because we use UTF-8 as the internal encoding in LLVM.
This patch defines a wrapper function which takes and returns UTF-8 string for
GetEnvironmentVariableW().

The wrapper function does not do any conversion and just forwards the argument
to getenv() on Unix.

Differential Revision: http://llvm-reviews.chandlerc.com/D1612

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190423 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 19:45:51 +00:00
NAKAMURA Takumi
16eedf0ba0 Support/Process: Add comments about PageSize and AllocationGranularity on Cygwin and Win32.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189940 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 14:12:26 +00:00
Daniel Dunbar
e179b31bfc [conf] Add config variable to disable crash related overrides.
- We do some nasty things w.r.t. installing or overriding signal handlers in
   order to improve our crash recovery support or interaction with crash
   reporting software, and those things are not necessarily appropriate when
   LLVM is being linked into a client application that has its own ideas about
   how to do things. This gives those clients a way to disable that handling at
   build time.

 - Currently, the code this guards is all Apple specific, but other platforms
   might have the same concerns so I went for a more generic configure
   name. Someone who is more familiar with library embedding on Windows can
   handle choosing which of the Windows/Signals.inc behaviors might make sense
   to go under this flag.

 - This also fixes the proper autoconf'ing of ENABLE_BACKTRACES. The code
   expects it to be undefined when disabled, but the autoconf check was just
   defining it to 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189694 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-30 20:39:21 +00:00
NAKAMURA Takumi
8fea8f2d82 Unix/Process.inc: Revert r72332, "Work around a page size issue on Cygwin."
Offset in mmap(3) should be aligned to gepagesize(), 64k, or mmap(3) would fail.

TODO: Invetigate places where 4096 would be required as pagesize, or 4096 would satisfy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188903 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 13:47:12 +00:00
Chandler Carruth
d485e7bd76 Go through the really awkward dance required to delete the memory
allocated by setupterm. Without this, some folks are seeing leaked
memory whenever this routine is called more than once. Thanks to Craig
Topper for the report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188615 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-18 01:20:32 +00:00
Aaron Ballman
0009850524 Removing unused functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188565 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-16 17:33:57 +00:00
Benjamin Kramer
d89266dd82 GCC warns about removing const with a c-style cast.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188259 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-13 09:57:55 +00:00
Chandler Carruth
3729d7d62b Remove all checking for the various terminfo headers (term.h and
curses.h). Finding these headers is next to impossible. For example, on
Debian systems libtinfo-dev provides the terminfo reading library we
want, but *not* term.h. For the header, you have to use libncurses-dev.
And libncursesw-dev provides a *different* term.h in a different
location!

These headers aren't worth it. We want two functions the signatures of
which are clearly spec'ed in sys-v and other documentation. Just declare
them ourselves and call them. This should fix some debian builders and
provide better support for "minimal" debian systems that do want color
autodetection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188165 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 10:40:11 +00:00
Chandler Carruth
8d8bdff6d7 Target a minimal terminfo library rather than necessarily a full curses
library for color support detection. This still will use a curses
library if that is all we have available on the system. This change
tries to use a smaller subset of the curses library, specifically the
subset that is on some systems split off into a separate library. For
example, if you install ncurses configured --with-tinfo, a 'libtinfo' is
install that provides just the terminfo querying functionality. That
library is now used instead of curses when it is available.

This happens to fix a build error on systems with that library because
when we tried to link ncurses into the binary, we didn't pull tinfo in
as well. =]

It should also provide an easy path for supporting the NetBSD
libterminfo library, but as I don't have access to a NetBSD system I'm
leaving adding that support to those folks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188160 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 09:49:17 +00:00
Rafael Espindola
0a69bac396 Check for $PWD in llvm::sys::current_path.
Some users (clang, libTooling) require this. After this patch we can remove
the calls to getenv("PWD") from clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188125 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-10 00:50:57 +00:00
Chandler Carruth
f7364d5833 Add support for linking against a curses library when available and
using it to detect whether or not a terminal supports colors. This
replaces a particularly egregious hack that merely compared the TERM
environment variable to "dumb". That doesn't really translate to
a reasonable experience for users that have actually ensured their
terminal's capabilities are accurately reflected.

This makes testing a terminal for color support somewhat more expensive,
but it is called very rarely anyways. The important fast path when the
output is being piped somewhere is already in place.

The global lock may seem excessive, but the spec for calling into curses
is *terrible*. The whole library is terrible, and I spent quite a bit of
time looking for a better way of doing this before convincing myself
that this was the fundamentally correct way to behave. The damage of the
curses library is very narrowly confined, and we continue to use raw
escape codes for actually manipulating the colors which is a much sane
system than directly using curses here (IMO).

If this causes trouble for folks, please let me know. I've tested it on
Linux and will watch the bots carefully. I've also worked to account for
the variances of curses interfaces that I could finde documentation for,
but that may not have been sufficient.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187874 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-07 08:47:36 +00:00
Rafael Espindola
e0913798bc Make file_status::getUniqueID const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187383 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-29 21:55:38 +00:00
Rafael Espindola
3ed45fe2be Include st_dev to make the result of getUniqueID actually unique.
This will let us use getUniqueID instead of st_dev directly on clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187378 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-29 21:26:49 +00:00
Rafael Espindola
496cf2308a Revert "[PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc."
This reverts commit r187248. It broke many bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187254 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 22:13:57 +00:00
Bill Schmidt
d063a326b2 [PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc.
Both GCC and LLVM will implicitly define __ppc__ and __powerpc__ for
all PowerPC targets, whether 32- or 64-bit.  They will both implicitly
define __ppc64__ and __powerpc64__ for 64-bit PowerPC targets, and not
for 32-bit targets.  We cannot be sure that all other possible
compilers used to compile Clang/LLVM define both __ppc__ and
__powerpc__, for example, so it is best to check for both when relying
on either inside the Clang/LLVM code base.

This patch makes sure we always check for both variants.  In addition,
it fixes one unnecessary check in lib/Target/PowerPC/PPCJITInfo.cpp.
(At least one of __ppc__ and __powerpc__ should always be defined when
compiling for a PowerPC target, no matter which compiler is used, so
testing for them is unnecessary.)

There are some places in the compiler that check for other variants,
like __POWERPC__ and _POWER, and I have left those in place.  There is
no need to add them elsewhere.  This seems to be in Apple-specific
code, and I won't take a chance on breaking it.

There is no intended change in behavior; thus, no test cases are
added.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187248 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 21:39:15 +00:00
Rafael Espindola
8b68480453 Add missing 'n'.
Thanks to Han Finkel for noticing it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187241 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 20:44:45 +00:00
Reid Kleckner
65985348c5 Remove dead or useless header checks from cmake and autoconf
On Windows, this improves clean cmake configuration time on my
workstation from 1m58s to 1m32s, which is pretty significant.  There's
probably more that can be done here, but this is the low hanging fruit.

Eric volunteered to regenerate ./configure for me.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187209 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 16:54:23 +00:00
Rafael Espindola
105a409679 Extend the lifetime of the strings passed to posix_spawn_file_actions_addopen.
Thanks to Hal Finkel for finding the bug and for the initial patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187208 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 16:21:31 +00:00
Rafael Espindola
b1a003f377 Split openFileForWrite into windows and unix versions.
It is similar to 186511, but for creating files for writing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-19 15:02:03 +00:00
Rafael Espindola
1c881d9d35 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186561 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-18 03:29:51 +00:00
Rafael Espindola
b0aa9e9718 Split openFileForRead into Windows and Unix versions.
This has some advantages:

* Lets us use native, utf16 windows functions.
* Easy to produce good errors on windows about trying to use a
directory when we want a file.
* Simplifies the unix version a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186511 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-17 14:58:25 +00:00
Rafael Espindola
f33cab4898 Don't fallback to copy + delete in rename.
Rename's documentation says "Files are renamed as if by POSIX rename()". and it
is used for atomically updating output files from a temporary. Having rename
fallback to a non atomic copy has the potential to hide bugs, like using
a temporary file in /tmp instead of a unique name next to the final destination.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186483 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-17 03:33:41 +00:00
Rafael Espindola
87be8d353b Add a version of sys::fs::status that uses fstat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186378 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 03:20:13 +00:00
Rafael Espindola
77e31bca03 Instead friending status, provide windows and posix constructors to file_status.
This opens the way of having static helpers in the .inc files that can
construct a file_status.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186376 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 02:55:33 +00:00
Craig Topper
793fd8d0d6 Revert part of 186302 to fix buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186303 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 04:37:54 +00:00
Craig Topper
b9df53a40b Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186301 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-15 04:27:47 +00:00
Rafael Espindola
71857ccdb8 Fix a FIXME about the format and add a test.
While at it, use strftime on Unix too and use the thread safe versions
of localtime.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186090 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 15:35:23 +00:00
Rafael Espindola
ac2de33d2a Use status to implement file_size.
The status function is already using a syscall that returns the file size.
Remember it and implement file_size as a simple wrapper.

No functionally change, but clients that already use status now can avoid
calling file_size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186016 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-10 17:16:40 +00:00
Rafael Espindola
1cce797d32 We now always create files with the correct permissions. Simplify the interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185834 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-08 16:42:01 +00:00
Eric Christopher
c589a5f284 Reapply r185601 with a fix for the cmake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185605 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04 01:10:38 +00:00
Eric Christopher
2333a31df5 Temporarily revert 185601 as it caused cmake build regressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185603 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04 00:51:26 +00:00
Eric Christopher
d1280c194b Add support for futimens for platforms that don't support futimes.
Patch by pashev.igor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185601 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-04 00:47:09 +00:00
Patrik Hagglund
363720e06c Suppress GCC "control reaches end of non-void function" warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185136 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-28 06:54:05 +00:00
Rafael Espindola
8e7294f995 Improvements to unique_file and createUniqueDirectory.
* Don't try to create parent directories in unique_file. It had two problem:
   * It violates the contract that it is atomic. If the directory creation
     success and the file creation fails, we would return an error but the
     file system was modified.
   * When creating a temporary file clang would have to first check if the
     parent directory existed or not to avoid creating one when it was not
     supposed to.

* More efficient implementations of createUniqueDirectory and the unique_file
  that produces only the file name. Now all 3 just call into a static
  function passing what they want (name, file or directory).

Clang also has to be updated, so tests might fail if a bot picks up this commit
and not the corresponding clang one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185126 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-28 03:48:47 +00:00
Rafael Espindola
7a231f5a1e Rename PathV2 to just Path now that it is the only one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185015 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26 19:33:03 +00:00
Rafael Espindola
97c2a0a110 Use enums instead of raw octal values.
Patch by 罗勇刚(Yonggang Luo).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184971 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26 17:28:04 +00:00
Rafael Espindola
460e75a453 PathV1 is deprecated since the 18th of Dec 2010. Remove it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184960 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-26 16:24:35 +00:00