234 Commits

Author SHA1 Message Date
Nico Weber
82811a8f50 [gn] fix minor mistake from f7cb1afa0633
The script printed two `/` when one suffices.
2024-01-17 06:43:22 -08:00
Nico Weber
f7cb1afa06 [gn] Make sync script print github URLs
Phab no longer knows about new revisions.
2024-01-09 10:58:23 -05:00
Arthur Eubanks
e02b85bef7
[gn build] Add a generic compiler_wrapper gn arg (#72757)
Since goma is going away soon, we need to experiment with other
wrappers.

We can clean up the goma stuff once it's fully non-functional.
2023-11-21 09:25:07 -08:00
Arthur Eubanks
2041611931 [gn build] Force clang_enable_per_target_runtime_dir for Android builds
Since it doesn't work yet.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D157901
2023-08-17 11:09:03 -07:00
Peter Collingbourne
1978482537 gn build: Fix Android build.
Remove --unwindlib=none flag that was added by D143598. It is required
to not pass this flag when linking binaries. With this flag, linking
e.g. llvm-symbolizer will fail.

There was a missing dependency from most targets to the implicitly linked
libraries (libunwind and builtins), which was causing the build for those
targets to fail when they were built on their own. I never noticed this
because I always build the implicitly linked libraries together with
their dependencies. Make the dependency explicit by introducing a new
target //llvm/utils/gn/build/libs/implicit representing the platform's
implicitly linked libraries, and depend on that from the LLVM libraries,
so that "normal" binaries like llvm-symbolizer will have all of their
dependencies available.

D143598 set the arch subdirectory to i686 for Android. However, the arch
subdirectory on Android is i386, and has been for a long time.

$ find android-ndk-r* -name i386
android-ndk-r18b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/7.0.2/lib/linux/i386
android-ndk-r19/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.2/lib/linux/i386
android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.7/lib/linux/i386
android-ndk-r21-beta1/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/lib/linux/i386
android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/lib/linux/i386
android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/11.0.5/lib/linux/i386
android-ndk-r23-beta5/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.5/lib/linux/i386
android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/i386
android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.7/lib/linux/i386

Using the wrong name prevents Clang from being able to find libunwind.a on
x86. Fix the code to use i386 as the arch subdirectory, consistent with
the NDK.

Bring back -Wl,-z,defs which was removed for Android by D143598, presumably
because of the missing unwind library.

Differential Revision: https://reviews.llvm.org/D146266
2023-08-01 17:41:21 -07:00
Leonard Grey
5e763d35e4 [gn] Add check-lsan target for Mac
Only supports ASAN mode right now. Standalone requires a some more plumbing so it will be a follow-up.

Mac-only but I suspect this will be fine on Linux also since it's based on the check-asan file, will follow up after testing.

Differential Revision: https://reviews.llvm.org/D153651
2023-07-06 13:03:16 -04:00
Tobias Hieta
b71edfaa4e
[NFC][Py Reformat] Reformat python files in llvm
This is the first commit in a series that will reformat
all the python files in the LLVM repository.

Reformatting is done with `black`.

See more information here:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: jhenderson, JDevlieghere, MatzeB

Differential Revision: https://reviews.llvm.org/D150545
2023-05-17 10:48:52 +02:00
Nico Weber
3cce68c2b3 [gn] Unbreak sync_source_lists_from_cmake on mac after Xcode update
Apparently `\b` stopped working with --pickaxe-regex for some reason.
2023-05-02 20:05:38 -04:00
Peter Collingbourne
659da71a40 gn build: Pass -fno-emulated-tls when targeting Android.
Matches the CMake build:
93c1a5f3dd/compiler-rt/CMakeLists.txt (L343)
(we always use API level 29).

Differential Revision: https://reviews.llvm.org/D146341
2023-03-17 17:28:40 -07:00
Arthur Eubanks
998ad085e8 Reland [gn build] Support linux/win compiler-rt cross compilation
Differential Revision: https://reviews.llvm.org/D143545
2023-02-17 09:58:28 -08:00
Arthur Eubanks
7a035de2d6 Revert "[gn build] Support linux/win compiler-rt cross compilation"
This reverts commit d73eb92cc673acf532b396537d78fe041dc9a9c2.

Breaks win/mac, e.g. http://45.33.8.238/win/75236/step_4.txt
2023-02-17 09:56:51 -08:00
Arthur Eubanks
d73eb92cc6 [gn build] Support linux/win compiler-rt cross compilation
Differential Revision: https://reviews.llvm.org/D143545
2023-02-17 09:33:28 -08:00
Arthur Eubanks
c8399811e7 [gn build] Support building x86/64 Android libraries
Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D143598
2023-02-17 09:18:38 -08:00
Arthur Eubanks
4089c28370 [gn build] Remove --rtlib=libgcc for Android builds
Recent Android NDKs don't ship with libgcc
2023-01-10 15:12:49 -08:00
Nico Weber
6bb781fa9a [gn build] Add build files for //bolt
Adds build files for libraries, tools, and tests -- everything except
the runtime.

Doesn't hook up bolt in the main BUILD.gn file yet -- I want to verify
that it builds on Linux, macOS, Windows before doing that. (I've only
checked on macOS so far.)

`ninja check-bolt` passes on macOS with this.
(I locally bumped the deployment target to macOS 10.12 for that. bolt/ uses
std::mutex quite a bit, which requires 10.12.)

Differential Revision: https://reviews.llvm.org/D138355
2022-11-21 19:45:54 -05:00
Nico Weber
20b0e0a71a [gn build] Stop defining GTEST_LANG_CXX11, pass /Zc:__cplusplus with msvc
Ports:
* https://reviews.llvm.org/D84023
* https://reviews.llvm.org/rG4f5ccc72f6a6e
  (but see https://reviews.llvm.org/rG4901199f5b84b223)

No intended behavior change.
2022-11-15 10:56:53 -05:00
Nico Weber
532c206141 [gn build] Reformat all build files
Ran:

    git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format
2022-10-11 11:04:43 -04:00
Zequan Wu
08d4d7cb8d [gn build] port a3172df59c32 (check-lldb)
https://reviews.llvm.org/rGa3172df59c32aac48c113eb7d6a1324aaa95c474 breaks
check-lldb gn build.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D133604
2022-09-13 10:52:56 -07:00
Nico Weber
d299c033e6 [gn build] Make it possible to do PGO-optimized builds
This is fairly manual for now.

Differential Revision: https://reviews.llvm.org/D131710
2022-08-11 18:39:46 -04:00
Nico Weber
c59c8a515f [gn build] port b1356504e63ae better (c++17) 2022-08-06 07:54:43 -04:00
Nico Weber
51a91d6c5d [gn build] port b1356504e63ae (c++17) 2022-08-06 07:51:06 -04:00
Nico Weber
a9b21ec484 [gn build] tweak how symbol_exports map files look on linux, for 94c00c10e
After bc39d7bdd497 (ported to GN in 94c00c10e), libclang uses symbol_exports,
and clang/test/LibClang/symbols.test wants the versioned name to be `LLVM_[0-9]$`
instead of `FOO`.
2022-07-26 01:52:00 -04:00
Nico Weber
b2998143a7 [gn build/mac] Use -mmacos-version-min instead of -mmacosx-version-min
The two flags do the same thing, but the OS is called macOS these days.

(The new flag is 5 years old: https://reviews.llvm.org/D32796)

No behavior change.
2022-07-07 23:56:37 +02:00
Nico Weber
52554f7315 [gn build] Allow use_ubsan=true on mac and unbreak use_asan, use_tsan, use_ubsan
`use_ubsan=true` seems to Just Work on macOS, so allow it.

https://reviews.llvm.org/D122862 broke use_asan=true, use_tsan=true, and
use_ubsan=true builds on Linux too. This makes this go again by explicitly
disabling asan, tsan, and ubsan for the baremetal part of the build. See
discussion on https://reviews.llvm.org/D122862 for other possible approaches.

Differential Revision: https://reviews.llvm.org/D127906
2022-06-15 19:34:35 -04:00
Nico Weber
0083a02839 [gn build] Slighly nicer gn args --list output for is_debug and symbol_level 2022-06-15 19:24:32 -04:00
Nico Weber
ceef00d33d [gn build] (manually) port 6bc8163c79fd 2022-06-10 06:26:31 -04:00
Nico Weber
7ed089153c [gn build] port f06abbb39380 a bit (create main() functions for GENERATE_DRIVER targets) 2022-06-06 06:28:52 -04:00
Nico Weber
10f7255d32 [gn build] Extract compiled_action.gni from tablegen.gni
After years of tablegen being the only host binary we run as part
of the build, we're now in the process of growing at least two more:
- make_confusable_table (https://reviews.llvm.org/rG180bae08a04d)
- pseudo-gen (not yet fully hooked up in the GN build, but I have
  a local branch that hooks it up)

Factor out the few lines we need for running a host binary as part of the
build.

No behavior change.

Differential Revision: https://reviews.llvm.org/D126963
2022-06-03 10:22:15 -04:00
Reid Kleckner
17296607a7 Revert "[Bazel][GN] Reuse the GN LLVM config file generation code"
This reverts commit e2ee8bf9818189b900e65d6ea8f1ae6fc75455ce.

This change is beyond my ability to integrate into Google's internal
build configuration tonight.
2022-05-31 21:15:46 -07:00
Reid Kleckner
e2ee8bf981 [Bazel][GN] Reuse the GN LLVM config file generation code
Currently, the Bazel build uses static, checked in [llvm-]config.h files
in combination with global macro definitions to mimic CMake's generated
headers. This change reuses the write_cmake_config.py script from the GN
build to generate the headers from source in the same way. The purpose
is to ensure that the Bazel build stays up to date with any changes to
the CMake config files. The write_cmake_config.py script has good error
checking to ensure that unneeded, stale variables are not passed, and
that any missing variables are reported as errors.

I tried to closely follow the logic in the GN build here:
  llvm/utils/gn/secondary/llvm/include/Config/BUILD.gn
The duplication between this file and config.bzl is significant, and we
could consider going further, but I'd like to hold off on it for now.

The GN build changes are to move the write_cmake_config.py script up to
//llvm/utils/write_cmake_config.py, and update the paths accordingly.

The next logical change is to generate Clang's config.h header.

Differential Revision: https://reviews.llvm.org/D126581
2022-05-31 19:40:05 -07:00
Arthur Eubanks
f37e6faf52 [gn build] Use llvm-ar when clang_base_path is specified
Only applies linux for now.

This prevents warnings with use_thinlto like
  bfd plugin: LLVM gold plugin has failed to create LTO module: Not an int attribute (Producer: 'LLVM15.0.0git' Reader: 'LLVM 13.0.1')

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D125399
2022-05-11 10:40:54 -07:00
Nico Weber
2ac876c52c [gn build] Fix a URL in a comment 2022-04-12 11:38:12 -04:00
Peter Collingbourne
38f9200945 gn build: Fix some tests for host_os to instead check current_os.
Should fix Windows build:
http://45.33.8.238/win/55809/step_4.txt
2022-04-06 15:45:51 -07:00
Peter Collingbourne
02a7b1754f Reland "gn build: Fix support for building the builtins for baremetal."
Our support for building for baremetal was conditional on a default
off arg and would have failed to build if you had somehow arranged
to pass the correct --target flag; presumably nobody noticed because
nobody was turning it on. A better approach is to model baremetal
as a separate "OS" called "baremetal" and build it in the same way
as we cross-compile for other targets. That's what this patch does.
I only hooked up the arm64 target but others can be added.

Relanding after fixing Mac build breakage in D123244.

Differential Revision: https://reviews.llvm.org/D122862
2022-04-06 13:45:40 -07:00
Peter Collingbourne
096477e25e gn build: Use target OS to control whether to use/depend on llvm-ar.
When cross-compiling from Mac to non-Mac, we need to use the just-built
llvm-ar instead of libtool. We're currently doing the right thing
when determining which archiver command to use, but the path to ar
and the toolchain dependencies were being set based on the host OS
(current_os evaluated in host OS toolchain), instead of the target
OS. Fix the problem by looking up current_os inside toolchain_args.

Differential Revision: https://reviews.llvm.org/D123244
2022-04-06 13:45:40 -07:00
Peter Collingbourne
d384f2b253 Revert "gn build: Fix support for building the builtins for baremetal."
This reverts commit b02b9b3dacc8a4afa96e8990f2dda8bc9b959f78.

Broke Mac build: http://45.33.8.238/macm1/32578/step_4.txt
2022-04-06 12:16:06 -07:00
Nico Weber
25b7efc9d1 Revert "[gn build] (manually) port 83a798d4b0e1 (abi_breaking_checks in tests)"
This reverts commit edddf384c22b039df8d3a31bbc86f9eb4945a65d.
83a798d4b0e1 was reverted in 62a983ebc570e8ffa3d.
2022-04-06 14:02:09 -04:00
Peter Collingbourne
b02b9b3dac gn build: Fix support for building the builtins for baremetal.
Our support for building for baremetal was conditional on a default
off arg and would have failed to build if you had somehow arranged
to pass the correct --target flag; presumably nobody noticed because
nobody was turning it on. A better approach is to model baremetal
as a separate "OS" called "baremetal" and build it in the same way
as we cross-compile for other targets. That's what this patch does.
I only hooked up the arm64 target but others can be added.

Differential Revision: https://reviews.llvm.org/D122862
2022-04-06 11:01:21 -07:00
Nico Weber
edddf384c2 [gn build] (manually) port 83a798d4b0e1 (abi_breaking_checks in tests) 2022-04-06 08:31:20 -04:00
Nico Weber
0ff3cc2087 [gn build] Change python run lines to python3
macOS 12.3 no longer ships non-3 python.

Almost all of these scripts were launched by ninja, and the GN files
already told it to run them under python3, so this is a fairly small
change.  The main effect is that if you run them manually, you now
get the same behavior.

(A small set of scripts, gn.py, gen.py, sync_source_lists_from_cmake.py,
are for manual running.  For these, it is an actual change.)

Differential Revision: https://reviews.llvm.org/D122345
2022-03-23 16:42:18 -04:00
Nico Weber
312ec6f156 [gn build] Use lld-link's new /winsysroot: flag
If `clang_base_path` is set, it must now point to a directory that contains
an lld-link built with D118070.

(If this is a problem for anyone, we can guard this behind a
lld_link_understands_winsysroot gn arg, but let's see if we can get away
without that for now.)

With this, it's possible to build everything in a normal cmd.exe Window,
an MSVC shell isn't needed \o/

(Assuming you set `clang_base_path`, and you set `sysroot` to a directory
that contains a win sysroot. If you have MSVC installed,
`python3 llvm\utils\sysroot.py make-fake --out-dir=my-sysroot` and
setting `sysroot = "//my-sysroot"` in args.gn works, for example.)

Differential Revision: https://reviews.llvm.org/D121871
2022-03-21 13:43:38 -04:00
Peter Collingbourne
aaca634c94 gn build: Add support for building with libcurl.
Differential Revision: https://reviews.llvm.org/D121260
2022-03-14 12:52:19 -07:00
Arthur Eubanks
81291b636d [gn build] Add -fsanitize=fuzzer to link flags in fuzzer targets when llvm_use_sanitize_coverage 2022-03-01 16:10:51 -08:00
Nico Weber
2df019ab5a [gn build] bump fmsc-version to 1926
This is needed to pick up the workaround in fb1aa286c1
when building with a modern MSVC (like LLVM now requires).
2022-02-22 17:47:27 -05:00
Arthur Eubanks
aaf2a47b1b [gn build] Set -fmsc-version=1920 on Windows
Now that the minimum version version of MSVC required to build LLVM has
been bumped, we see

  ../../llvm/include\llvm/Support/Compiler.h(94,2): error: LLVM requires
  at least VS 2019.
  #error LLVM requires at least VS 2019.

e.g. http://45.33.8.238/win/53703/step_4.txt

1920 corresponds to the earliest version of VS 2019.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D118713
2022-02-03 15:56:02 -08:00
Arthur Eubanks
0c425b43b9 [gn build] Add support for check-asan
With these changes, check-asan passes on Linux and Windows.

There are a couple libraries we need to add support for, asan_static, asan_preinit, and the shared library version of asan proper.
Since we need to build the asan proper sources twice, once with -DASAN_DYNAMIC and once without, those sources are no longer in a source_set.
Much of the check-asan target is taken from the existing check-hwasan target.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D118307
2022-01-27 16:09:43 -08:00
Arthur Eubanks
f73f367f72 [gn build] Move -fno-builtin to crt_code
crt_code seems to correspond to SANITIZER_COMMON_CFLAGS which contains -fno-builtin.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D118288
2022-01-26 18:33:35 -08:00
Nico Weber
65146382b3 [gn build] Remove unhelpful default for goma_dir
The default hasn't worked in over 9 months now.

Getting a friendly error message if this isn't set is more useful than getting
a bad default value.

Differential Revision: https://reviews.llvm.org/D115833
2021-12-15 18:39:53 -05:00
Nico Weber
1217b4b46f [gn build] Build with Fission on non-mac non-win when using lld
In release+sym builds (-O2 -g), reduces time to link `clang`
from 2.3s to 1.3s (-42%).

In debug builds (-g), reduces time to link `clang`
from 5.4s to 4.5s (-17.4%).

See the phab review for full `ministat` numbers.

In the CMake build this is opt-in via LLVM_USE_SPLIT_DWARF.
Since the GN build is targeted at developers, enabling it by default
seems like a better default setting here. (If it turns out to cause
problems, we can add an opt-out.)

Time to load the binary into gdb and to set a breakpoint is unchanged.
Time from `run` to hitting a breakpoint in `main` feel a bit faster
(~4s -> ~2s), but I dind't do a careful statistical anlysis for this.

Differential Revision: https://reviews.llvm.org/D115040
2021-12-03 11:07:52 -05:00
Quinn Pham
76313f8ec9 [NFC][gn build] Inclusive language: replace master with main in sync_source_lists_from_cmake.py
[NFC] As part of using inclusive language within the llvm project and to
match the renamed master branch, this patch replaces master with main in
sync_source_lists_from_cmake.py.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D113926
2021-11-17 09:32:15 -06:00