Skip to content
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

Support to fetch remote toolchain package when building project #1217

Closed
5 tasks done
waruqi opened this issue Jan 28, 2021 · 2 comments
Closed
5 tasks done

Support to fetch remote toolchain package when building project #1217

waruqi opened this issue Jan 28, 2021 · 2 comments

Comments

@waruqi
Copy link
Member

waruqi commented Jan 28, 2021

we can fetch cross toolchain or the special version of clang/gcc/llvm/mingw

Supported toolchains in xmake-repo

  • llvm
  • gnu-rm
  • muslcc (musl.cc)
  • llvm-mingw
  • zig

set_toolchains

toolchain_name@package_name_or_alias

add_requires("llvm 11.x", {alias = "llvm-11"})
set_toolchains("llvm@llvm-11")

@toolchain_package_name

if toolchain name and package name are same

add_requires("llvm")
set_toolchains("@llvm")

Only use toolchain, do not bind toolchain package

It will not fetch remote toolchain package.

set_toolchains("llvm")

fetch cross toolchain

add_requires("muslcc")
target("test")
    set_kind("binary")
    add_files("src/*.c)
    set_toolchains("@muslcc")

fetch the special version of clang

add_requires("clang 10.x")
target("test")
    set_kind("binary")
    add_files("src/*.c")
    set_toolchains("clang", {packages = {"clang", ...}})

fetch the special version of llvm

Full example: https://github.com/xmake-io/xmake/tree/dev/tests/projects/package/toolchain_llvm

add_requires("llvm 10.x", {alias = "llvm-10"})
target("test")
    set_kind("binary")
    add_files("src/*.c)
    set_toolchains("llvm@llvm-10")

fetch zig toolchain

Full example: https://github.com/xmake-io/xmake/tree/dev/tests/projects/package/toolchain_zig

add_requires("zig 0.8.x")
target("test")
    set_kind("binary")
    add_files("src/*.zig")
    set_toolchains("@zig")

fetch other compiler

add_requires("tinyc")
target("test")
    set_kind("binary")
    add_files("src/*.c")
    set_toolchains("@tinyc")

Switch to global cross-compilation toolchain for targets/packages

Full example: https://github.com/xmake-io/xmake/tree/dev/tests/projects/package/toolchain_muslcc

add_rules("mode.debug", "mode.release")

-- set cross-compliation platform
set_plat("cross")
set_arch("arm")

-- add toolchains package
add_requires("muslcc")

-- add library packages
add_requires("zlib", "libogg",  {system = false})

-- set global toolchains for target and packages
set_toolchains("@muslcc")

target("test")
    set_kind("binary")
    add_files("src/*.c")
    add_packages("zlib", "libogg")
@waruqi waruqi added this to the v2.5.2 milestone Jan 28, 2021
@xq114
Copy link
Contributor

xq114 commented Jan 29, 2021

This is really a nice feature! The version control of gcc et al. has been a problem on linux for long, since the compile process is too complicated for the most. Some system packages like update-alternatives lack many versions. Moreover, the conflict between system gcc and custom gcc is also a problem. See #1087

@waruqi
Copy link
Member Author

waruqi commented Feb 16, 2021

This is really a nice feature! The version control of gcc et al. has been a problem on linux for long, since the compile process is too complicated for the most. Some system packages like update-alternatives lack many versions. Moreover, the conflict between system gcc and custom gcc is also a problem. See #1087

I have initially implemented this feature on the dev branch. And added llvm/llvm-mingw/muslcc/gnu-rm/zig toolchains to xmake-repo

if you want to see all examples, please see https://github.com/xmake-io/xmake/tree/dev/tests/projects/package

But because I don’t have much free time and the gcc toolchain is complicated, I haven’t added the gcc toolchain to xmake-repo.

@waruqi waruqi closed this as completed Feb 16, 2021
@waruqi waruqi pinned this issue Feb 27, 2021
@waruqi waruqi unpinned this issue Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants