Page MenuHomePhabricator

[CMake][libc] Support cross-compiling libc-hdrgen
ClosedPublic

Authored by phosek on Jan 21 2021, 10:57 PM.

Details

Summary

This is useful when cross-compiling libc to another target in which
case we first need to compile libc-hdrgen for host. We rely on the
existing LLVM CMake infrastructure for that.

Diff Detail

Event Timeline

phosek created this revision.Jan 21 2021, 10:57 PM
phosek requested review of this revision.Jan 21 2021, 10:57 PM

Note that there's one additional issue right now. The TableGen cross-compilation sub-invokes CMake which fails with:

CMake Error at /src/clang-llvm/llvm-project/libc/CMakeLists.txt:49 (message):


        'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to
        lint llvm-libc. The linting step performs important checks to help prevent
        the introduction of subtle bugs, but it may increase build times.



        To disable linting set LLVM_LIBC_ENABLE_LINTING to OFF
        (pass -DLLVM_LIBC_ENABLE_LINTING=OFF to cmake).


-- Configuring incomplete, errors occurred!

I think we'll need some way detect when we're cross-compiling TableGen and disable the linting support in that case.

phosek updated this revision to Diff 318428.Jan 21 2021, 11:02 PM

Note that there's one additional issue right now. The TableGen cross-compilation sub-invokes CMake which fails with:

CMake Error at /src/clang-llvm/llvm-project/libc/CMakeLists.txt:49 (message):


        'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to
        lint llvm-libc. The linting step performs important checks to help prevent
        the introduction of subtle bugs, but it may increase build times.



        To disable linting set LLVM_LIBC_ENABLE_LINTING to OFF
        (pass -DLLVM_LIBC_ENABLE_LINTING=OFF to cmake).


-- Configuring incomplete, errors occurred!

I think we'll need some way detect when we're cross-compiling TableGen and disable the linting support in that case.

We can take simpler route of not enabling linting by default. Developer workflow will involve testing with linting enabled of course.

sivachandra accepted this revision.Jan 25 2021, 9:20 PM
This revision is now accepted and ready to land.Jan 25 2021, 9:20 PM

Note that there's one additional issue right now. The TableGen cross-compilation sub-invokes CMake which fails with:

CMake Error at /src/clang-llvm/llvm-project/libc/CMakeLists.txt:49 (message):


        'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to
        lint llvm-libc. The linting step performs important checks to help prevent
        the introduction of subtle bugs, but it may increase build times.



        To disable linting set LLVM_LIBC_ENABLE_LINTING to OFF
        (pass -DLLVM_LIBC_ENABLE_LINTING=OFF to cmake).


-- Configuring incomplete, errors occurred!

I think we'll need some way detect when we're cross-compiling TableGen and disable the linting support in that case.

We can take simpler route of not enabling linting by default. Developer workflow will involve testing with linting enabled of course.

I'm fine with that, it'd also simplify integrating libc into the runtimes build where I'm also hitting this issue.

phosek updated this revision to Diff 319947.Jan 28 2021, 1:14 PM
This revision was automatically updated to reflect the committed changes.