aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-rc/llvm-rc.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-29[LLVM][Cygwin] Enable conditions that are shared with MinGW (#149638)jeremyd20191-1/+1
Cygwin and MinGW share the auto import behavior that could result in __stack_check_guard being non-dso-local. Allow windres to assume a Cygwin target as well as a MinGW one, so defines like _WIN32 would not be present on Cygwin.
2025-04-14[tools] Use llvm::append_range (NFC) (#135721)Kazu Hirata1-3/+2
2025-03-29[bugpoint] Avoid repeated hash lookups (NFC) (#133616)Kazu Hirata1-2/+1
2024-12-11Rework the `Option` library to reduce dynamic relocations (#119198)Chandler Carruth1-12/+20
Apologies for the large change, I looked for ways to break this up and all of the ones I saw added real complexity. This change focuses on the option's prefixed names and the array of prefixes. These are present in every option and the dominant source of dynamic relocations for PIE or PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which has a huge number of options. This PR addresses this by building a string table and a prefixes table that can be referenced with indices rather than pointers that require dynamic relocations. This removes almost 7k dynmaic relocations from the `clang` binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For busy-boxing use cases where many different option tables are linked into the same binary, the savings add up a bit more. The string table is a straightforward mechanism, but the prefixes required some subtlety. They are encoded in a Pascal-string fashion with a size followed by a sequence of offsets. This works relatively well for the small realistic prefixes arrays in use. Lots of code has to change in order to land this though: both all the option library code has to be updated to use the string table and prefixes table, and all the users of the options library have to be updated to correctly instantiate the objects. Some follow-up patches in the works to provide an abstraction for this style of code, and to start using the same technique for some of the other strings here now that the infrastructure is in place.
2024-09-25[SystemZ][z/OS] Open text files in text mode (#109972)Abhina Sree1-2/+2
This patch continues the work that was started here https://reviews.llvm.org/D99426 to correctly open text files in text mode.
2024-01-31[llvm-rc] Support ARM64EC resource generation (#78908)Billy Laws1-1/+4
This is already supported in llvm-cvtres, so only a small change is needed.
2024-01-19[tools] Use SmallString::operator std::string (NFC)Kazu Hirata1-1/+1
2024-01-11[llvm-driver] Fix usage of `InitLLVM` on Windows (#76306)Alexandre Ganea1-2/+0
Previously, some tools such as `clang` or `lld` which require strict order for certain command-line options, such as `clang -cc1` or `lld -flavor`, would not longer work on Windows, when these tools were linked as part of `llvm-driver`. This was caused by `InitLLVM` which was part of the `*_main()` function of these tools, which in turn calls `windows::GetCommandLineArguments`. That function completly replaces argc/argv by new UTF-8 contents, so any ajustements to argc/argv made by `llvm-driver` prior to calling these tools was reset. `InitLLVM` is now called by the `llvm-driver`. Any tool that participates in (or is part of) the `llvm-driver` doesn't call `InitLLVM` anymore.
2023-12-18[llvm-windres] Change the interpretation of --preprocessor to match Binutils ↵Martin Storsjö1-39/+5
2.36 (#75391) Binutils 2.36 had a somewhat controversial change in how the --preprocessor option was handled in GNU windres; previously, the option was interpreted as a part of the command string, potentially containing multiple arguments (which even was hinted at in the documentation). In Binutils 2.36, this was changed to interpret the --preprocessor argument as one argument (possibly containing spaces) pointing at the preprocessor executable. The existing behaviour where implicit arguments like -E -xc -DRC_INVOKED are dropped if --preprocessor is specified, was kept. This was a breaking change for some users of GNU windres, see https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=21c33bcbe36377abf01614fb1b9be439a3b6de20, https://sourceware.org/bugzilla/show_bug.cgi?id=27594, and https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5edb8e3f5ad8d74a83fc0df7f6e4514eed0aa77f. As multiple years have passed since, the behaviour change seems to be here to stay, and any users of the previous form of the option have been forced to avoid this construct. Thus update llvm-windres to match the new way Binutils of handling this option. One construct for specifying the path to the preprocessor, which works both before and after binutils 2.36 (and this change in llvm-windres) is to specify options like this: --preprocessor path/to/executable --preprocessor-arg -E --preprocessor-arg -xc -DRC_INVOKED
2023-12-15[llvm-windres] Resolve the --preprocessor executable in $PATH (#75390)Martin Storsjö1-2/+15
The llvm::sys::ExecuteAndWait function doesn't resolve the file to be executed from $PATH - i.e. it is similar to execv(), not execvp(). Due to this, specifying a --preprocessor argument to llvm-windres only worked if it specified an absolute path to the preprocessor executable. This was observed as one of the issues in https://github.com/msys2/MINGW-packages/pull/19157. Before d2fa6b694c2052cef1ddd507f6569bc84e3bbe35, this usage of --preprocessor seemed to work, because the first argument of Args[] was ignored and llvm-windres just executed the autodetected clang executable regardless. Also improve the error messages printed if preprocessing failed. (If the preprocessor executable was started but itself returned an error, we don't get any error string.)
2023-12-15[llvm-windres] Pass user preprocessor arguments before the input filename ↵Martin Storsjö1-2/+2
(#75389) If passing the windres option --preprocessor, the default arguments "-E -xc -DRC_INVOKED" aren't passed. If these are passed explicitly by the user via --preprocessor-arg instead, we need to make sure that "-xc" is passed before the input filename, as this compiler/preprocessor option only has an effect on input files that follow it. This fixes one of the issues with llvm-windres observed in https://github.com/msys2/MINGW-packages/pull/19157.
2023-09-01[llvm-windres] Implement the windres flag --use-temp-fileMartin Storsjö1-4/+13
Whether a temp file or a pipe is used for preprocessing is an internal detail, this flag has a notable effect on the preprocessing in GNU windres. Without this flag, GNU windres passes command arguments as-is to popen(), which means they get evaluated by a shell without being re-escaped for this case. To mimic this, llvm-windres has manually tried to unescape arguments. When GNU windres is given the --use-temp-file flag, it uses a different API for invoking the preprocessor, and this API takes care of preserving special characters in the command line arguments. For users of GNU windres, this means that by using --use-temp-file, they don't need to do the (quite terrible) double escaping of quotes/spaces etc. The xz project uses the --use-temp-file flag when invoking GNU windres, see https://github.com/tukaani-project/xz/commit/6b117d3b1fe91eb26d533ab16a2e552f84148d47. However as llvm-windres didn't implement this flag and just assumed the GNU windres popen() behaviour, they had to use a different codepath for llvm-windres. That separate codepath for llvm-windres broke later when llvm-windres got slightly more accurate unescaping of lone quotes in 0f4c6b120f21d582ab7c5c4f2b2a475086c34938 / https://reviews.llvm.org/D146848 (fixing a discrepancy to GNU windres as found in https://github.com/llvm/llvm-project/issues/57334), and this was reported in https://github.com/mstorsjo/llvm-mingw/issues/363. Not touching the implementation of the --preprocessor option with respect to the --use-temp-file flag; that option is doubly tricky as GNU windres changed its behaviour in a backwards incompatible way recently (and llvm-windres currently matches the old behaviour). (See https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=21c33bcbe36377abf01614fb1b9be439a3b6de20, https://sourceware.org/bugzilla/show_bug.cgi?id=27594 and https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5edb8e3f5ad8d74a83fc0df7f6e4514eed0aa77f;hp=3abbafc2aacc6706fea3e3e326e2f08d107c3672 for the behaviour change.) Differential Revision: https://reviews.llvm.org/D159223
2023-08-28[llvm-rc] Continue to use Argv[0] to resolve executable pathAmy Huang1-6/+10
In internal google builds, MainExecPath doesn't go to the directory with `clang`. Fall back to using Argv0 if MainExecPath doesn't find any clangs. Differential Revision: https://reviews.llvm.org/D158901
2023-08-15Reapply "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner1-0/+1
This reverts commit 4e3b89483a6922d3f48670bb1c50a37f342918c6, with fixes for places I'd missed updating in lld and lldb. I've also renamed OptionVisibility::Default to "DefaultVis" to avoid ambiguity since the undecorated name has to be available anywhere Options.inc is included. Original message follows: This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-14Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner1-1/+0
this is failing on bots, reverting to investigate. This reverts commit a16104e6da6f36f3d72dbf53d10ba56495a0d65a.
2023-08-14[Option] Add "Visibility" field and clone the OptTable APIs to use itJustin Bogner1-0/+1
This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-08[llvm-rc] Resolve the executable path if not present in Argv[0]Martin Storsjö1-1/+7
The llvm-rc tool tries to locate a suitable Clang executable to use for preprocessing. For this purpose, it first checks within the same directory as the llvm-rc tool, checking with a couple different names, followed by checking all of $PATH for another couple names. On Windows, the InitLLVM() function always sets up Argv[0] with the full path to the executable, while on Unix, Argv[0] is kept as is. Therefore, call getMainExecutable to try to resolve the directory of the executable before looking for colocated Clang executables. This makes 282744a9ce18120dc0a6eceb02693b36980d9498 actually have the desired effect. Differential Revision: https://reviews.llvm.org/D157241
2023-08-04[llvm] Extract common `OptTable` bits into macrosJan Svoboda1-19/+6
All command-line tools using `llvm::opt` create an enum of option IDs and a table of `OptTable::Info` object. Most of the tools use the same ID (`OPT_##ID`), kind (`Option::KIND##Class`), group ID (`OPT_##GROUP`) and alias ID (`OPT_##ALIAS`). This patch extracts that common code into canonical macros. This results in fewer changes when tweaking the `OPTION` macros emitted by the TableGen backend. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157028
2023-07-07[llvm-rc] Improve help printoutsMartin Storsjö1-1/+2
This more clearly identifies the tool as llvm-rc. This should hopefully allow Meson to check for parts of these strings in the output of "$CMD /?" when detecting the kind of resource compiler tool, to allow Meson to recognize llvm-rc. Differential Revision: https://reviews.llvm.org/D154545
2023-03-28[lvm-windres] Try to match GNU windres regarding handling of unescaped quotesMartin Storsjö1-0/+3
Some background context: GNU windres invokes the preprocessor in a subprocess. Some windres options are passed through to the preproocessor, e.g. -D options for predefining defines. When GNU windres passes these options onwards, it takes the options in exact the form they are received (in argv or similar) and assembles them into a single preprocessor command string which gets interpreted by a shell (IIRC via the popen() function, or similar). When LLVM invokes subprocesses, it does so via APIs that take properly split argument vectors, to avoid needing to worry about shell quoting/escaping/unescaping. But in the case of LLVM windres, we have to emulate the effect of the shell parsing done by popen(). Most of the relevant cases are already taken care of here, but this patch fixes an uncommon case encountered in https://github.com/llvm/llvm-project/issues/57334. (This case is uncommon since it doesn't do what one would want to; the quotes need to be escaped more to work as intended through the popen() shell). Differential Revision: https://reviews.llvm.org/D146848
2023-03-28[llvm-rc] Remove transitional preprocessing fallback logicMartin Storsjö1-10/+6
When preprocessing was integrated to llvm-rc in 2021, this was a new requirement (previously one could execute llvm-rc without a suitable preprocessing tool to be available). As a transitional helper, llvm-rc fell back on skipping preprocessing if no suitable tool was found (with a warning printed), but users could pass an llvm-rc specific option to silence the warning, if they explicitly want to run the tool without preprocessing. Now 2 years later, remove the transitional helper - error out if preprocessing failed. The option for disabling preprocessing remains. Differential Revision: https://reviews.llvm.org/D146797
2023-03-28[llvm-rc] Fix the reference to the option for disabling preprocessing in a ↵Martin Storsjö1-3/+9
message This was the original option name from the first iteration of the patch that added the feature, but during review, a different name was suggested and preferred - but the reference in the helpful message was missed. Differential Revision: https://reviews.llvm.org/D146796
2023-03-28[llvm-rc] Look for "clang-<major>" when locating a suitable preprocessorMartin Storsjö1-1/+4
In some cases, there's no adjacent executable named "clang" or "clang-cl", but one name "clang-<major>". This logic doesn't cover every possible deployment setup of course, but should cover more fairly common/reasonable cases. See https://github.com/curl/curl-for-win/commit/caaae171ac43af5b883403714dafd42030d8de61#commitcomment-105808524 for discussion about a case where this would have been helpful. Differential Revision: https://reviews.llvm.org/D146794
2023-03-28[llvm-rc] Respect the executable specified in the --preprocessor commandMartin Storsjö1-2/+2
The arguments passed in this option were passed onto the child process, but we still blindly used the clang binary that we had found to sys::ExecuteAndWait as the intended executable to run. If the user hasn't specified any custom --preprocessor command, Args[0] is equal to the variable Clang. This doesn't affect any tests, since the tests only print the arguments it would try to execute (but not the first parameter to sys::ExecuteAndWait), but there's no testes for executing it (and validating that it did execute the right thing). Differential Revision: https://reviews.llvm.org/D146793
2023-02-10[llvm-driver] Pass extra arguments to toolsAlex Brachet1-1/+2
Differential Revision: https://reviews.llvm.org/D137799
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott1-1/+1
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-01-12[OptTable] Precompute OptTable prefixes union table through tablegenserge-sans-paille1-4/+4
This avoid rediscovering this table when reading each options, providing a sensible 2% speedup when processing and empty file, and a measurable speedup on typical workloads, see: This is optional, the legacy, on-the-fly, approach can still be used through the GenericOptTable class, while the new one is used through PrecomputedOptTable. https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u Differential Revision: https://reviews.llvm.org/D140800
2023-01-05Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ partserge-sans-paille1-2/+2
Use deduction guides instead of helper functions. The only non-automatic changes have been: 1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*)) 2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase. 3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated. 4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that). Per reviewers' comment, some useless makeArrayRef have been removed in the process. This is a follow-up to https://reviews.llvm.org/D140896 that introduced the deduction guides. Differential Revision: https://reviews.llvm.org/D140955
2022-12-27[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille1-10/+20
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This a recommit of e953ae5bbc313fd0cc980ce021d487e5b5199ea4 and the subsequent fixes caa713559bd38f337d7d35de35686775e8fb5175 and 06b90e2e9c991e211fecc97948e533320a825470. The above patchset caused some version of GCC to take eons to compile clang/lib/Basic/Targets/AArch64.cpp, as spotted in aa171833ab0017d9732e82b8682c9848ab25ff9e. The fix is to make BuiltinInfo tables a compilation unit static variable, instead of a private static variable. Differential Revision: https://reviews.llvm.org/D139881
2022-12-25Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵Vitaly Buka1-20/+10
builtin and call information" Revert "Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4 (part 2)" Revert "Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4" GCC build hangs on this bot https://lab.llvm.org/buildbot/#/builders/37/builds/19104 compiling CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.d The bot uses GNU 11.3.0, but I can reproduce locally with gcc (Debian 12.2.0-3) 12.2.0. This reverts commit caa713559bd38f337d7d35de35686775e8fb5175. This reverts commit 06b90e2e9c991e211fecc97948e533320a825470. This reverts commit e953ae5bbc313fd0cc980ce021d487e5b5199ea4.
2022-12-24[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille1-10/+20
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This is a recommit of 719d98dfa841c522d8d452f0685e503538415a53 that into account a GGC issue (probably https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92181) when dealing with intiailizer_list and constant expressions. Workaround this by avoiding initializer list, at the expense of a temporary plain old array. Differential Revision: https://reviews.llvm.org/D139881
2022-12-23Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵serge-sans-paille1-17/+11
builtin and call information" There are still remaining issues with GCC 12, see for instance https://lab.llvm.org/buildbot/#/builders/93/builds/12669 This reverts commit 5ce4e92264102de21760c94db9166afe8f71fcf6.
2022-12-23[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille1-11/+17
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This is a recommit of 719d98dfa841c522d8d452f0685e503538415a53 with a change to llvm/utils/TableGen/OptParserEmitter.cpp to cope with GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 Differential Revision: https://reviews.llvm.org/D139881
2022-12-23Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵serge-sans-paille1-17/+11
builtin and call information" Failing builds: https://lab.llvm.org/buildbot#builders/9/builds/19030 This is GCC specific and has been reported upstream: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 This reverts commit 719d98dfa841c522d8d452f0685e503538415a53.
2022-12-23[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille1-11/+17
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139881
2022-12-08Store OptTable::Info::Name as a StringRefserge-sans-paille1-2/+2
This is a recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e, with a few cleanups. This avoids implicit conversion to StringRef at several points, which in turns avoid redundant calls to strlen. As a side effect, this greatly simplifies the implementation of StrCmpOptionNameIgnoreCase. It also eventually gives a consistent, humble speedup in compilation time (timing updated since original commit). https://llvm-compile-time-tracker.com/compare.php?from=de4b6a1bc64db33643f001ad45fae7b92b4a4688&to=c23a93d1292052b4be2fbe8c586fa31143d0c7ed&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139274
2022-10-06[llvm-driver] Add various tools to the llvm-driverAlex Brachet1-3/+3
The llvm-driver, enabled with LLVM_TOOL_LLVM_DRIVER_BUILD combines many llvm executables into one to save overall toolchain size. This patch adds a few more llvm tools to the llvm-driver. Differential Revision: https://reviews.llvm.org/D135281
2022-07-07Remove unnecessary includes of ManagedStatic.hNicolai Hähnle1-1/+0
Differential Revision: https://reviews.llvm.org/D129115
2022-02-09[llvm-rc]: Find <target>-clang over just clangTobias Hieta1-3/+4
This patch makes llvm-rc/windres prefer <target>-clang over clang when doing it's preprocessing. This is so that we can have a .cfg file for <target> and configure sysroot and other important flags. Config files not picked up with clang --target=<target> automatically. We only look for <target>-clang in the same dir as llvm-windres and not for all PATHs to minimize the change. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D119219
2021-10-18[tools] Delete redundant 'static' from namespace scope 'static const'. NFCFangrui Song1-2/+2
2021-08-05[llvm-rc] Allow specifying language with a leading 0x prefixMartin Storsjö1-4/+7
This option is always interpreted strictly as a hexadecimal string, even if it has no prefix that indicates the number format, hence the existing call to StringRef::getAsInteger(16, ...). StringRef::getAsInteger(0, ...) consumes a leading "0x" prefix is present, but when the radix is specified, the radix shouldn't be included. Both MS rc.exe and GNU windres accept the language with that prefix. Also allow specifying the codepage to llvm-windres with a different radix, as GNU windres allows that (but MS rc.exe doesn't). This fixes https://llvm.org/PR51295. Differential Revision: https://reviews.llvm.org/D107263
2021-07-28[llvm] Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]Fangrui Song1-1/+1
[[noreturn]] can be used since Oct 2016 when the minimum compiler requirement was bumped to GCC 4.8/MSVC 2015. Note: the definition of LLVM_ATTRIBUTE_NORETURN is kept for now.
2021-06-25[llvm-rc] Don't rewrite the arch in the default triple unless necessaryMartin Storsjö1-6/+13
When the default target arch isn't one that is supported as a windows target, we want to set a suitable architecture (so that Clang tests that run plain 'llvm-rc' succeed checks for e.g. "#ifdef _WIN32" even for llvm builds that default to e.g. ppc64). But if the default target architecture is usable, don't rewrite it. (Rewriting it, by e.g. "T.setArch(T.getArch())", normalizes the spelling of the architecture, e.g. changing i686 to i386. Such a change can make clang unable to find the right sysroot.) This can't, unfortunately, practically be tested very well because it is entirely dependent on the default triple of the llvm build. Differential Revision: https://reviews.llvm.org/D104589
2021-06-24[OptTable] Rename PrintHelp to printHelpFangrui Song1-2/+2
To be consistent with other member functions and match the coding standard.
2021-06-25[llvm] Rename StringRef _lower() method calls to _insensitive()Martin Storsjö1-3/+3
This is a mechanical change. This actually also renames the similarly named methods in the SmallString class, however these methods don't seem to be used outside of the llvm subproject, so this doesn't break building of the rest of the monorepo.
2021-06-22[ADT] Add StringRef consume_front_lower and consume_back_lowerMartin Storsjö1-10/+3
These serve as a convenient combination of consume_front/back and startswith_lower/endswith_lower, consistent with other existing case insensitive methods named <operation>_lower. Differential Revision: https://reviews.llvm.org/D104218
2021-04-26[llvm-rc] Add a GNU windres-like frontend to llvm-rcMartin Storsjö1-101/+507
This primarily parses a different set of options and invokes the same resource compiler as llvm-rc normally. Additionally, it can convert directly to an object file (which in MSVC style setups is done with the separate cvtres tool, or by the linker). (GNU windres also supports other conversions; from coff object file back to .res, and from .res or object file back to .rc form; that's not yet implemented.) The other bigger complication lies in being able to imply or pass the intended target triple, to let clang find the corresponding mingw sysroot for finding include files, and for specifying the default output object machine format. It can be implied from the tool triple prefix, like `<triple>-[llvm-]windres` or picked up from the windres option e.g. `-F pe-x86-64`. In GNU windres, that option takes BFD style format names such as pe-i386 or pe-x86-64. As libbfd in binutils doesn't support Windows on ARM, there's no such canonical name for the ARM targets. Therefore, as an LLVM specific extension, this option is extended to allow passing full triples, too. Differential Revision: https://reviews.llvm.org/D100756
2021-04-21[llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 ↵Martin Storsjö1-4/+19
architectures When llvm-rc invokes clang for preprocessing, it uses a target triple derived from the default target. The test verifies that e.g. _WIN32 is defined when preprocessing. If running clang with e.g. -target ppc64le-windows-msvc, that particular arch/OS combination isn't hooked up, so _WIN32 doesn't get defined in that configuration. Therefore, the preprocessing test fails. Instead make llvm-rc inspect the architecture of the default target. If it's one of the known supported architectures, use it as such, otherwise set a default one (x86_64). (Clang can run preprocessing with an x86_64 target triple, even if the x86 backend isn't enabled.) Also remove superfluous llvm:: specifications on enums in llvm-rc.cpp.
2021-04-21[llvm-rc] Run clang to preprocess input filesMartin Storsjö1-1/+116
Allow opting out from preprocessing with a command line argument. Update tests to pass -no-preprocess to make it not try to use clang (which isn't a build level dependency of llvm-rc), but add a test that does preprocessing under clang/test/Preprocessor. Update a few options to allow them both joined (as -DFOO) and separate (-D BR), as rc.exe allows both forms of them. With the verbose flag set, this prints the preprocessing command used (which differs from what rc.exe does). Tests under llvm/test/tools/llvm-rc only test constructing the preprocessor commands, while tests under clang/test/Preprocessor test actually running the preprocessor. Differential Revision: https://reviews.llvm.org/D100755