New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial adding LLVM 6.0 Toolchain #5574

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@xiangzhai

xiangzhai commented Nov 24, 2017

Hi ARMmbed developers,

Description

Build ARMmbed mbed-os-example-wifi for REALTEK_RTL8195AM target via LLVM Toolchain based on clang compiler, lld linker, llvm-objcopy, musl libc, llvm's libcxx and compiler-rt.

Status

IN DEVELOPMENT

Todos

  • Link with lib_peripheral_mbed_llvm.a and lib_wlan_mbed_llvm.a
  • Introduce how to use LLVM Toolchain to build wlan library for targets

Steps to test or reproduce

Follow the "Building Clang and Working with the Code" section in Getting Started: Building and Running Clang, after step 3, it also needs to check out lld:

cd llvm/tools
svn co http://llvm.org/svn/llvm-project/lld/trunk lld

cmake build option tested for Fedora 25:

cmake .. -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/opt/llvm-svn \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_C_FLAGS="-fPIC" \
    -DCMAKE_CXX_FLAGS="-std=c++11 -fPIC" \
    -DLLVM_BUILD_LLVM_DYLIB=ON \
    -DLLVM_LINK_LLVM_DYLIB=ON \
    -DLLVM_INSTALL_UTILS=ON \
    -DLLVM_ENABLE_RTTI=ON \
    -DLLVM_ENABLE_FFI=ON \
    -DLLVM_ENABLE_EH=ON \
    -DLLVM_BUILD_TESTS=ON \
    -DLLVM_BUILD_DOCS=OFF \
    -DLLVM_ENABLE_SPHINX=OFF \
    -DLLVM_ENABLE_DOXYGEN=OFF \
    -DLLDB_DISABLE_LIBEDIT=1 \
    -DSPHINX_WARNINGS_AS_ERRORS=OFF \
    -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
    -DFFI_LIBRARY_DIR:PATH="$(pkg-config --variable=libdir libffi)" \
    -DLLVM_BINUTILS_INCDIR=/usr/include \
    -DLLVM_LIBDIR_SUFFIX=64 \
    -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON \
    -DLIBUNWIND_ENABLE_SHARED=ON \
    -DLIBCXXABI_USE_LLVM_UNWINDER=ON \
    -DLLVM_BUILD_EXAMPLES=OFF \
    -DLLDB_TEST_C_COMPILER=clang \
    -DLLDB_TEST_CXX_COMPILER=clang++ \
    -DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-redhat-linux" \
    -DCLANG_VENDOR="Fedora"

configure build option for musl libc:

LLVM_SVN_BIN=/opt/llvm-svn/bin

export PATH=$PATH:$LLVM_SVN_BIN
export CC=$LLVM_SVN_BIN"/clang --target=thumbv7em-unknown-none-eabi -mthumb -march=armv7e-m -mcpu=cortex-m3 -mfloat-abi=soft -mfpu=fpv5-sp-d16 -ffreestanding -mlittle-endian -mimplicit-it=always"
export LD=$LLVM_SVN_BIN"/ld.lld"

./configure --build=arm-none-eabi \
    --host=x86_64-redhat-gnu \
    --target=arm-none-eabi \
    --prefix=/opt/arm-musl \
    --disable-shared

Also it is able to download ellcc libraries including musl, libcxx and compiler-rt, etc. for armv7e-m.

Copy the Makefile template and run make to build.

Regards,
Leslie Zhai - a LLVM developer https://reviews.llvm.org/p/xiangzhai/

Initial adding LLVM 6.0 Toolchain.
It is based on clang compiler, lld linker, llvm-objcopy, musl libc, llvm's libcxx and compiler-rt.

@0xc0170 0xc0170 requested a review from theotherjimmy Nov 24, 2017

@0xc0170

This comment has been minimized.

Show comment
Hide comment
@0xc0170

0xc0170 Nov 24, 2017

Member

Our target is to support armcc6, the feature is being developed on https://github.com/ARMmbed/mbed-os/tree/feature-armc6 branch. Most of these changes should be also there, as armcc6 uses clang-based as front end compiler - armclang.

@theotherjimmy please review

Member

0xc0170 commented Nov 24, 2017

Our target is to support armcc6, the feature is being developed on https://github.com/ARMmbed/mbed-os/tree/feature-armc6 branch. Most of these changes should be also there, as armcc6 uses clang-based as front end compiler - armclang.

@theotherjimmy please review

@xiangzhai

This comment has been minimized.

Show comment
Hide comment
@xiangzhai

xiangzhai Nov 24, 2017

Hi @0xc0170 thanks for your kind response! I will rebase my patch based on feature-armc6 branch next week :)

xiangzhai commented Nov 24, 2017

Hi @0xc0170 thanks for your kind response! I will rebase my patch based on feature-armc6 branch next week :)

@xiangzhai

This comment has been minimized.

Show comment
Hide comment
@xiangzhai

xiangzhai Nov 24, 2017

Hi @0xc0170 take mbed_retarget.h for an instance, master branch is beyond than feature-armc6 branch a little. So it is better to maintain two branches for my work? or when do you plan to merge feature-armc6 branch into master? please give me some hint, thanks a lot!

xiangzhai commented Nov 24, 2017

Hi @0xc0170 take mbed_retarget.h for an instance, master branch is beyond than feature-armc6 branch a little. So it is better to maintain two branches for my work? or when do you plan to merge feature-armc6 branch into master? please give me some hint, thanks a lot!

@theotherjimmy

This comment has been minimized.

Show comment
Hide comment
@theotherjimmy

theotherjimmy Nov 27, 2017

Contributor

@0xc0170 Please don't retarget this PR.

Contributor

theotherjimmy commented Nov 27, 2017

@0xc0170 Please don't retarget this PR.

@theotherjimmy

This comment has been minimized.

Show comment
Hide comment
@theotherjimmy

theotherjimmy Nov 27, 2017

Contributor

@xiangzhai Please don't retarget this PR. I will rebase feature-armc6 as appropriate.

This is great!

We use Mbed CLI as a frontend our native build system for Mbed OS, and the backend for mbed compile (an Mbed CLI command) is present as the tools/ directory in this repo. These build tools are written in Python > 2.7.11 and can compile all of Mbed OS for any target described in targets.json with Arm Compilers 5 and 6, IAR EWARM and GCC with the target triple arm-none-eabi. I would like to see clang/llvm added to this list, and it looks like you have started that work. Do you plan on adding another toolchain for clang/llvm to these build tools? If you would like any assistance in adding a toolchain, please ask me! I'll do my best to he helpful.

It may be appropriate to use a feature branch to coordinate these changes, as They might get big.

Contributor

theotherjimmy commented Nov 27, 2017

@xiangzhai Please don't retarget this PR. I will rebase feature-armc6 as appropriate.

This is great!

We use Mbed CLI as a frontend our native build system for Mbed OS, and the backend for mbed compile (an Mbed CLI command) is present as the tools/ directory in this repo. These build tools are written in Python > 2.7.11 and can compile all of Mbed OS for any target described in targets.json with Arm Compilers 5 and 6, IAR EWARM and GCC with the target triple arm-none-eabi. I would like to see clang/llvm added to this list, and it looks like you have started that work. Do you plan on adding another toolchain for clang/llvm to these build tools? If you would like any assistance in adding a toolchain, please ask me! I'll do my best to he helpful.

It may be appropriate to use a feature branch to coordinate these changes, as They might get big.

@xiangzhai

This comment has been minimized.

Show comment
Hide comment
@xiangzhai

xiangzhai Nov 28, 2017

Hi @theotherjimmy

Thanks for your kind response!

it looks like you have started that work

Sorry, I am not familiar with mbed compile, so I use Makefile to build RTOS, Realtek RTL8195A target, I might change to ST DISCO_L475VG_IOT01A target owing to #5517 and ST provided the wifi module's source code, HAL, PLATFORM, DRIVERS, FEATURES (netsocket, lwip, mbedtls, filesystem) and EVENTS via my patched LLVM Toolchain.

Do you plan on adding another toolchain for clang/llvm to these build tools? If you would like any assistance in adding a toolchain, please ask me! I'll do my best to he helpful.

I need to be familiar with Mbed CLI and tools directory firstly, then I will try to add LLVM Toolchain with your code review :)

Regards,
Leslie Zhai

xiangzhai commented Nov 28, 2017

Hi @theotherjimmy

Thanks for your kind response!

it looks like you have started that work

Sorry, I am not familiar with mbed compile, so I use Makefile to build RTOS, Realtek RTL8195A target, I might change to ST DISCO_L475VG_IOT01A target owing to #5517 and ST provided the wifi module's source code, HAL, PLATFORM, DRIVERS, FEATURES (netsocket, lwip, mbedtls, filesystem) and EVENTS via my patched LLVM Toolchain.

Do you plan on adding another toolchain for clang/llvm to these build tools? If you would like any assistance in adding a toolchain, please ask me! I'll do my best to he helpful.

I need to be familiar with Mbed CLI and tools directory firstly, then I will try to add LLVM Toolchain with your code review :)

Regards,
Leslie Zhai

@adbridge

This comment has been minimized.

Show comment
Hide comment
@adbridge

adbridge Dec 29, 2017

Contributor

@xiangzhai Please don't use merge commits in PRs. Please rebase instead. Merge commits cause problems when cherry picking PRs over to patch release branches. Although this particulare PR may need to go to the next Minor release in which case it would be less of an issue.

Contributor

adbridge commented Dec 29, 2017

@xiangzhai Please don't use merge commits in PRs. Please rebase instead. Merge commits cause problems when cherry picking PRs over to patch release branches. Although this particulare PR may need to go to the next Minor release in which case it would be less of an issue.

@mbed-ci

This comment has been minimized.

Show comment
Hide comment
@mbed-ci

mbed-ci Dec 29, 2017

Automatic CI verification build not done, please verify manually.

mbed-ci commented Dec 29, 2017

Automatic CI verification build not done, please verify manually.

@xiangzhai

This comment has been minimized.

Show comment
Hide comment
@xiangzhai

xiangzhai commented Dec 30, 2017

@adbridge sorry!

@xiangzhai xiangzhai closed this Jan 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment