1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_toolchain: 2*61c4878aSAndroid Build Coastguard Worker 3*61c4878aSAndroid Build Coastguard Worker================ 4*61c4878aSAndroid Build Coastguard WorkerLLVM compiler-rt 5*61c4878aSAndroid Build Coastguard Worker================ 6*61c4878aSAndroid Build Coastguard WorkerThe ``$dir_pw_third_party/llvm_builtins/`` directory provides the GN integration 7*61c4878aSAndroid Build Coastguard Workernecessary to link against LLVM compiler-rt project. The intention here is to use 8*61c4878aSAndroid Build Coastguard Workerthe builtins provided by the LLVM compiler-rt project. 9*61c4878aSAndroid Build Coastguard Worker 10*61c4878aSAndroid Build Coastguard Worker------------------------------- 11*61c4878aSAndroid Build Coastguard WorkerUsing upstream LLVM compiler-rt 12*61c4878aSAndroid Build Coastguard Worker------------------------------- 13*61c4878aSAndroid Build Coastguard WorkerIf you want to use LLVM compiler-rt, you must do the following: 14*61c4878aSAndroid Build Coastguard Worker 15*61c4878aSAndroid Build Coastguard WorkerSubmodule 16*61c4878aSAndroid Build Coastguard Worker========= 17*61c4878aSAndroid Build Coastguard WorkerAdd LLVM compiler-rt to your workspace with the following command. 18*61c4878aSAndroid Build Coastguard Worker 19*61c4878aSAndroid Build Coastguard Worker.. code-block:: sh 20*61c4878aSAndroid Build Coastguard Worker 21*61c4878aSAndroid Build Coastguard Worker git submodule add git submodule add \ 22*61c4878aSAndroid Build Coastguard Worker https://llvm.googlesource.com/llvm-project/compiler-rt \ 23*61c4878aSAndroid Build Coastguard Worker third_party/llvm_builtins 24*61c4878aSAndroid Build Coastguard Worker 25*61c4878aSAndroid Build Coastguard Worker.. admonition:: Note 26*61c4878aSAndroid Build Coastguard Worker 27*61c4878aSAndroid Build Coastguard Worker This git repository is maintained by Google and is a slice of upstream 28*61c4878aSAndroid Build Coastguard Worker LLVM including only the compiler-rt subdirectory. 29*61c4878aSAndroid Build Coastguard Worker 30*61c4878aSAndroid Build Coastguard WorkerGN 31*61c4878aSAndroid Build Coastguard Worker== 32*61c4878aSAndroid Build Coastguard Worker* Set the GN var ``dir_pw_third_party_llvm_builtins`` to the location of the 33*61c4878aSAndroid Build Coastguard Worker LLVM compiler-rt source. If you used the command above, this will be 34*61c4878aSAndroid Build Coastguard Worker ``//third_party/llvm_builtins`` 35*61c4878aSAndroid Build Coastguard Worker 36*61c4878aSAndroid Build Coastguard Worker This can be set in your args.gn or .gn file like: 37*61c4878aSAndroid Build Coastguard Worker ``dir_pw_third_party_llvm_builtins = "//third_party/llvm_builtins"`` 38*61c4878aSAndroid Build Coastguard Worker 39*61c4878aSAndroid Build Coastguard Worker* Set the ``pw_third_party_llvm_builtins_TARGET_BUILTINS`` to the pw_source_set 40*61c4878aSAndroid Build Coastguard Worker that selectively adds the files required for the given architecture from the 41*61c4878aSAndroid Build Coastguard Worker LLVM compiler-rt checkout directory. 42*61c4878aSAndroid Build Coastguard Worker 43*61c4878aSAndroid Build Coastguard Worker For example, you can add the following in your args.gn or .gn file to use the 44*61c4878aSAndroid Build Coastguard Worker builtins for ARMv7-M targets. 45*61c4878aSAndroid Build Coastguard Worker 46*61c4878aSAndroid Build Coastguard Worker .. code-block:: 47*61c4878aSAndroid Build Coastguard Worker 48*61c4878aSAndroid Build Coastguard Worker pw_third_party_llvm_builtins_TARGET_BUILTINS = "$dir_pw_third_party/llvm_builtins:arm_builtins_armv7m" 49*61c4878aSAndroid Build Coastguard Worker 50*61c4878aSAndroid Build Coastguard Worker* Set the optional ``pw_third_party_llvm_builtins_ignore_list`` to the list of 51*61c4878aSAndroid Build Coastguard Worker files included in pw_source_sets in ``$dir_pw_third_party/llvm_builtins/BUILD.gn`` file. 52