All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederick Gotham <cauldwell.thomas@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] Where the cross-compiler gets shared stuff
Date: Fri, 22 Nov 2019 08:00:48 -0000 (UTC)	[thread overview]
Message-ID: <XnsAB0F51847D9ABfgotham@195.159.176.226> (raw)

Typically, when a cross-compiler is installed properly on a computer, do you 
need to explicitly invoke it with "--sysroot=/opt/targetfs", or is this 
parameter already implied if the cross-compiler is properly installed? 

Right now I'm working on an embedded Linux project, and I'm using Buildroot 
to produce a minimalistic Linux installation with only the programs and 
libraries I need. 

I see that some 3rd party packages invoke the correct cross-compiler but they 
don't give the "--sysroot" parameter. 

For example, if we start off with the following native compilation command:

    gcc main.c -o prog 

Then a correct cross-compilation would be: 

    CC = /opt/project/build/output/host/bin/x86_64-buildroot-linux-gnu-gcc 
    SYSROOT = /opt/project/build/output/host/x86_64-buildroot-linux-
gnu/sysroot 

    $(CC) --sysroot=$(SYSROOT) main.c -o prog 

I see however that some packages are leaving out the sysroot parameter, and 
so they're just doing: 

    $(CC) main.c -o prog 

This predictably fails if the host and the target have different CPU's, for 
example if my office PC is x86_64 and my target is embedded Linux ARM 
aarch64. 

On my current project though, the host and the target have the same CPU, and 
so if you leave out the "--sysroot" parameter then the program ends up 
linking with shared libraries installed on the host. Sometimes this happens 
without any compiler warning or error! 

So how are cross-compilers supposed to work? If they are installed properly, 
do you need to give them the "--sysroot" parameter?

Note that I'm prefering the use of "--sysroot" instead of using the following 
two options: -I$(STAGING_DIR)/usr/include -L$(STAGING_DIR)/usr/lib.

             reply	other threads:[~2019-11-22  8:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22  8:00 Frederick Gotham [this message]
2019-11-22  9:37 ` [Buildroot] Where the cross-compiler gets shared stuff Thomas Preston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=XnsAB0F51847D9ABfgotham@195.159.176.226 \
    --to=cauldwell.thomas@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.