Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 views
in Technique[技术] by (71.8m points)

autoconf - How to determine host value for configure when using cross compiler

General question: If I use a cross compiler, how can I tell the value of the "--host" option I should give when I run configure?

Specific: I'm using cross compiler for arm64 arch. What is the correct "--host" value to use?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If I use a cross compiler, how can I tell the value of the --host option I should give when I run ./configure?

Three machines must be distinguished when discussing toolchain creation

  • The build machine, where the toolchain is built.
  • The host machine, where the toolchain will be executed.
  • The target machine, where the binaries created by the toolchain are executed.

Four common build types are possible for toolchains are:

  • Native build i.e. BUILD==HOST==TARGET
    Used to build normal gcc for workstation. e.g. BUILD==HOST==TARGET==x86

  • Cross-build i.e. BUILD==HOST!=TARGET
    Used to build toolchain that works on your workstation but generates binary for target. e.g. BUILD==HOST==x86 TARGET==arm

  • Cross-native build i.e. BUILD!=HOST==TARGET
    Used to toolchain that works on your target and generates binary for target. e.g BUILD==x86 HOST==TARGET==ARM

  • Canadian toolchain i.e. BUILD!=HOST!=TARGET
    Used to build ARCHITECTURE A a toolchain runs on B and generates binary for architecture C. e.g.BUILD==x86 HOST==mac TARGET==arm

With armed this basics coming to your question.

For any software, first run ./configure --help

Host type:

--build=BUILD           configure for building on BUILD [BUILD=HOST]
--host=HOST             configure for HOST [guessed]
--target=TARGET         configure for TARGET [TARGET=HOST]

You will find above so depending on what you want to do, you need to set it for cross compiling. If all options are available, then you want to execute on arm target then set --host={your toolchain triplet} --target={your toolchain triplet}.

For example, if you are using arm-none-linux-gnueabi-gcc, set --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi. This will write to your makefile. Finally, generated executable will run on target. For --build this will be automatically set, no need to worry.

For some software package only two option available i.e host and build. here if set host is enough to cross-compile

Specific: I'm using cross compiler for arm64 arch. What is the correct --host value to use?

For x86_64, --host={triplet} is generally given, so I think the same should work for arm64 by setting --host={triplet} for your toolchain, but I'm not sure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...