Skip to content

Commit ab286cc

Browse files
committed
🐛 Fix missing env & cmake definitions for native builds
- Add ar, ld, nm, objcopy, objdump, ranlib, strip to cpp_info executables - Expand CMake variables to include all compiler and utility tools - Define standard environment variables (CC, CXX, AS, AR, LD, NM, etc.) in buildenv - Add README section documenting how to build tools for platforms using the toolchain
1 parent c62e42d commit ab286cc

4 files changed

Lines changed: 55 additions & 4 deletions

File tree

.github/workflows/verify.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ jobs:
7878
- name: 📦 Build Demos Conan Package
7979
if: ${{ runner.os == 'Windows' }}
8080
run: conan build demos/cpp-modules -pr llvm-${{ inputs.version }} -pr ${{ inputs.demo_profile }}
81+
82+
- name: ⚙️ Build ninja for build platform from scratch
83+
if: conan install --tool-requires="ninja/1.13.2" --build="ninja/*" -pr:a llvm-${{ inputs.version }} -pr:a ${{ inputs.demo_profile }}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,15 @@ Once you've verified everything works:
520520
2. Submit a pull request with a clear description of the version being added
521521
3. Include any platform-specific notes or limitations
522522
4. Note any version mismatches between upstream LLVM and ARM Embedded Toolchain
523+
524+
### Testing Building tools for Platforms
525+
526+
The `llvm-toolchain` can not only be used to build applications for a target
527+
but also the build tools themselves. For example, if the prebuilt binary for
528+
Ninja doesn't exist for your platform, your platform will need to build it.
529+
530+
The command to build the Ninja
531+
532+
```bash
533+
conan install --tool-requires="ninja/1.13.2" --build="ninja/*" -pr:a hal/tc/llvm -pr:a hal/os/mac
534+
```

all/conanfile.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,23 +463,50 @@ def package_info(self):
463463
"c": "clang",
464464
"cpp": "clang++",
465465
"asm": "clang",
466+
"ar": "llvm-ar",
467+
"ld": "lld",
468+
"nm": "llvm-nm",
469+
"objcopy": "llvm-objcopy",
470+
"objdump": "llvm-objdump",
471+
"ranlib": "llvm-ranlib",
472+
"strip": "llvm-strip",
466473
})
467474

468-
# Add CMake utility tools
475+
# Add CMake compiler and utility tools
469476
cmake_extra_variables = {
477+
"CMAKE_C_COMPILER": "clang",
478+
"CMAKE_CXX_COMPILER": "clang++",
479+
"CMAKE_ASM_COMPILER": "clang",
480+
"CMAKE_LINKER": "lld",
481+
"CMAKE_AR": "llvm-ar",
482+
"CMAKE_NM": "llvm-nm",
470483
"CMAKE_OBJCOPY": "llvm-objcopy",
471-
"CMAKE_SIZE_UTIL": "llvm-size",
472484
"CMAKE_OBJDUMP": "llvm-objdump",
473-
"CMAKE_AR": "llvm-ar",
474485
"CMAKE_RANLIB": "llvm-ranlib",
475-
"CMAKE_CXX_SCAN_FOR_MODULES": "ON",
486+
"CMAKE_STRIP": "llvm-strip",
487+
"CMAKE_SIZE_UTIL": "llvm-size",
488+
"CMAKE_ADDR2LINE": "llvm-addr2line",
476489
"CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_DEPENDENCIES": "1942b4fa-b2c5-4546-9385-83f254070067",
477490
}
478491

479492
self.conf_info.update(
480493
"tools.cmake.cmaketoolchain:extra_variables", cmake_extra_variables)
481494

482495
self.buildenv_info.define("LLVM_INSTALL_DIR", self.package_folder)
496+
self.buildenv_info.define("CC", "clang")
497+
self.buildenv_info.define("CXX", "clang++")
498+
self.buildenv_info.define("AS", "clang")
499+
self.buildenv_info.define("AR", "llvm-ar")
500+
self.buildenv_info.define("LD", "lld")
501+
self.buildenv_info.define("NM", "llvm-nm")
502+
self.buildenv_info.define("OBJCOPY", "llvm-objcopy")
503+
self.buildenv_info.define("OBJDUMP", "llvm-objdump")
504+
self.buildenv_info.define("RANLIB", "llvm-ranlib")
505+
self.buildenv_info.define("SIZE", "llvm-size")
506+
self.buildenv_info.define("STRINGS", "llvm-strings")
507+
self.buildenv_info.define("STRIP", "llvm-strip")
508+
self.buildenv_info.define("ADDR2LINE", "llvm-addr2line")
509+
self.buildenv_info.define("GDB", "lldb")
483510

484511
if self.settings_target:
485512
self.add_common_flags()

conan/profiles/v1/llvm-20

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ compiler.cppstd=23
44
compiler.libcxx=libc++
55
compiler.version=20
66

7+
{% if context == "host" %}
8+
79
[tool_requires]
810
llvm-toolchain/20
911
cmake/[>=3.28.0 <5.0.0]
1012
ninja/[^1.0.0]
1113

1214
[conf]
1315
tools.cmake.cmaketoolchain:generator=Ninja
16+
17+
{% elif context == "build" %}
18+
19+
[tool_requires]
20+
!llvm-toolchain/*:llvm-toolchain/20,cmake/[>=3.28.0 <5.0.0]
21+
22+
{% endif %}

0 commit comments

Comments
 (0)