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

custom toolchain indexing (arch info) fails #912

Closed
ghost opened this issue Jul 31, 2020 · 15 comments
Closed

custom toolchain indexing (arch info) fails #912

ghost opened this issue Jul 31, 2020 · 15 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 31, 2020

Describe the bug

proceeded according to https://xmake.io/#/manual/custom_toolchain and created custom toolchain

toolchain("my_llvm")
  set_kind("standalone")
  set_toolset("cc", "clang-10")
  set_toolset("cxx", "clang++-10")
  set_toolset("ar", "llvm-ar-10")
  set_toolset("ld", "ld.lld-10")
  set_toolset("nm", "llvm-nm-10")
  set_toolset("objcopy", "llvm-objcopy-10")
  set_toolset("objdump", "llvm-objdump-10")
  set_toolset("objsize", "llvm-size-10")
  set_toolset("strip" , "llvm-strip-10")
  set_toolset("readelf", "llvm-readelf-10")
  set_toolset("hostcc", "clang-10")
  set_toolset("hostcxx", "clang++-10")
  set_toolset("hostar", "llvm-ar-10")
  set_toolset("hostld", "ld.lld-10")

  add_defines("my_llvm")

  on_check(function (toolchain)
    return import("lib.detect.find_tool")("clang-10")
  end)
toolchain_end()

Expected behavior

indexing for custom toolchain to pass

Error output

xmake f -cvD
checking for the architecture ... x86_64
error: @programdir/core/main.lua:284: @programdir/core/tool/toolchain.lua:94: attempt to index field '_INFO' (a nil value)

Related Environment

Please provide compiling and running environment information:

  • xmake version: 2.3.6+202007282035
  • os: linux/x86_64

Additional context

Also set arch = "x86_64" in xmake.conf (globaldir) which is met with the same error

@waruqi waruqi added the bug label Aug 1, 2020
@waruqi waruqi added this to the v2.3.7 milestone Aug 1, 2020
@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

I have fixed this problem, you can update to dev branch and try it again.

$ xmake update -s dev
$ xmake f --toolchain=my_llvm -c
$ xmake

@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

  set_toolset("nm", "llvm-nm-10")
  set_toolset("objcopy", "llvm-objcopy-10")
  set_toolset("objdump", "llvm-objdump-10")
  set_toolset("objsize", "llvm-size-10")
  set_toolset("strip" , "llvm-strip-10")
  set_toolset("readelf", "llvm-readelf-10")
  set_toolset("hostcc", "clang-10")
  set_toolset("hostcxx", "clang++-10")
  set_toolset("hostar", "llvm-ar-10")
  set_toolset("hostld", "ld.lld-10")

we only support these the toolset key types cc, cxx, ld, ar, sh, strip, .. now.

you can see https://xmake.io/#/manual/project_target?id=targetset_toolset

we need not nm, objcopy, objsize, objdump, readelf, hostcc, hostar ...

@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

toolchain("my_llvm")
  set_kind("standalone")
  set_toolset("cc", "clang-10")
  set_toolset("cxx", "clang++-10")
  set_toolset("ar", "llvm-ar-10")
  set_toolset("ld", "clang++-10")  -- we need clang++ as ld to link libc++ library when compile c++ program
  set_toolset("sh", "clang++-10") -- for linking shared library
  set_toolset("strip" , "llvm-strip-10") 

  add_defines("my_llvm")

  -- optional, If you are sure that you can run clang-10 successfully, you can return true directly, or remove on_check
  on_check(function (toolchain)
    return import("lib.detect.find_tool")("clang-10")
  end)
toolchain_end()

@ghost
Copy link
Author

ghost commented Aug 1, 2020

xmake update -s dev does not work update_log.txt

and neither does sudo xmake update -svD dev producing

kinfo: cannot runv(/usr/bin/unzip -v), Permission denied
checkinfo: cannot runv(unzip -v), Permission denied
checking for the unzip ... no
error: @programdir/core/main.lua:284: @programdir/actions/require/impl/environment.lua:42: unzip not found! we need install it firstcheckinfo: cannot runv(/usr/bin/unzip -v), Permission denied
checkinfo: cannot runv(unzip -v), Permission denied
checking for the unzip ... no
error: @programdir/core/main.lua:284: @programdir/actions/require/impl/environment.lua:42: unzip not found! we need install it first

executing unzip -v or sudo unzip -v from cli does not produce such (permission denied) error.

@ghost
Copy link
Author

ghost commented Aug 1, 2020

Despite the issue with xmake update -s the script appears to have been updated and the repoted error does not exhibit:

xmake f -cyvD
checking for the clang ... no
checking for the clang-10 ... /usr/bin/clang-10
checking for the c compiler (cc) ... clang-10
checking for the /usr/bin/clang-10 ... ok
checking for the flags (-fcolor-diagnostics) ... ok
> clang-10 "-fcolor-diagnostics" "-Qunused-arguments"
checking for the ccache ... /usr/bin/ccache
checking for the llvm-ar-10 ... /usr/bin/llvm-ar-10
checking for the static library archiver (ar) ... llvm-ar-10

we need not nm, objcopy, objsize, objdump, readelf, hostcc, hostar ...

that I do not understand - some source code specify those in their makefiles - could you explain why Xmake does not need those?

@ghost ghost closed this as completed Aug 1, 2020
@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

xmake update -s dev does not work

Please try run xmake update dev

that I do not understand - some source code specify those in their makefiles - could you explain why Xmake does not need those

xmake does not rely on makefile/make, usually does not use readelf/nm to build the program.

@ghost
Copy link
Author

ghost commented Aug 1, 2020

xmake update dev works fine; only with the -s handle it produces the previously reported permission error(s).

@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

xmake update dev works fine; only with the -s handle it produces the previously reported permission error(s).

This is because -s will only update lua scripts without binary program and directly overwrite the /usr/local/share directory files(Because you installed make install before, the installation directory is /usr/local instead of ~/.local/xmake), so there may be no permissions, but xmake update dev will install all to the ~/.local/xmake directory without permission issues

@ghost
Copy link
Author

ghost commented Aug 1, 2020

being represented with

  • error
  • permission denied
  • failed

sort of leaves one (least it does me) with the impression that things went wrong, more so that the full update process by comparison does not produce such

@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

You can run xmake update dev/master perform a complete update every time without -s.

After appending -s, it will only update the Lua script, which will be slightly faster, so I added the -s parameter to you earlier.

@ghost
Copy link
Author

ghost commented Aug 1, 2020

It is ok now that I know that -s works despite the exhibited error.

What is the difference between the dev and the master branch, since https://github.com/xmake-io/xmake/compare/dev does not show any?

@waruqi
Copy link
Member

waruqi commented Aug 1, 2020

Currently these two branches are the same, dev is the development branch, bug fixes and feature updates will be pushed to the dev branch first, and then I will merge to the master branch after stable.

@ghost
Copy link
Author

ghost commented Aug 1, 2020

minor issue

xmake show -l toolchains
error: the toolchain my_llvm not found!

this one https://github.com/xmake-io/xmake/blob/dev/xmake/core/tool/toolchain.lua#L423 raising it?

@waruqi
Copy link
Member

waruqi commented Aug 2, 2020

I have fixed it, you can update to dev version and try it again. xmake update dev

@ghost
Copy link
Author

ghost commented Aug 2, 2020

confirmed as fixed

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant