All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sedat Dilek <sedat.dilek@gmail.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Clang-Built-Linux ML <clang-built-linux@googlegroups.com>,
	linux-kbuild@vger.kernel.org
Subject: Using GNU AS from a selfmade binutils v2.35.2
Date: Fri, 5 Feb 2021 11:56:55 +0100	[thread overview]
Message-ID: <CA+icZUUjb_71mWwWFMYN_OPZir2vStLq1kDY1O+JCFjtmEEBjA@mail.gmail.com> (raw)

Hi Masahiro and ClangBuiltLinux folks,

I am trying to use binaries from GNU/binutils v2.35.2 for my
Linux-kernel builds.

Background is I am doing some testing for BTF + pahole with GCC-10 and LLVM-12.

I tried several strategies.

[ STRATEGY #1 - Use a-local-binutils.conf LDCONFIG ]

[ /etc/ld.so.conf.d/a-local-binutils.conf ]

# Selfmade GNU/binutils lib configuration
/opt/binutils/lib
- EOT -

sudo ldconfig
sudo ldconfig -v -p
...shows me above lib path is in the ldconfig-cache.

In my build-script I additionally add:

BINUTILS_BIN_PATH="/opt/binutils/bin"
if [ -d ${BINUTILS_BIN_PATH} ]; then
    export PATH="${BINUTILS_BIN_PATH}:${PATH}"
fi

That's NOT including ld.bfd from /opt/binutils/bin - not including nm,
ar, strip etc.

NOTE: Symlink: lrwxrwxrwx 1 root   root     15  5. Feb 11:10
/opt/binutils -> binutils-2.35.2

[ STRATEGY #2 - Use LD_LIBRARY_PATH ]

From my build-script:

BINUTILS_BIN_PATH="/opt/binutils/bin"
BINUTILS_LIB_PATH="/opt/binutils/lib"
if [ -d ${BINUTILS_BIN_PATH} ] && [ -d ${BINUTILS_LIB_PATH} ]; then
   export PATH="${BINUTILS_BIN_PATH}:${PATH}"
   export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BINUTILS_LIB_PATH}"
fi

That's not working either.
New PATH and LD_LIBRARY_PATH are set in the user's environment variables.

[ STRATEGY #3 - Use which to get full path to binary ]

### GCC version settings
GCC_MAJOR_VER="10"

### Compiler options
CC_FOR_BUILD="clang"
CXX_FOR_BUILD="clang++"

### Linker options
##LD_FOR_BUILD="ld.bfd"
LD_FOR_BUILD=$(which ld.bfd)

### GNU tools options
# NOTE: Selfmade GNU AS v2.35.2 needs to be symlinked in /usr/bin directory
# XXX: Symlink: /usr/bin/as -> /opt/binutils-2.35.2/bin/as
HOSTAR_FOR_BUILD=$(which ar)
AR_FOR_BUILD=$(which ar)
NM_FOR_BUILD=$(which nm)
STRIP_FOR_BUILD=$(which strip)
OBJCOPY_FOR_BUILD=$(which objcopy)
OBJDUMP_FOR_BUILD=$(which objdump)
READELF_FOR_BUILD=$(which readelf)
GNU_TOOLS_OPTS="HOSTCC=${CC_FOR_BUILD} HOSTCXX=${CXX_FOR_BUILD}
HOSTLD=${LD_FOR_BUILD} HOSTAR=${HOSTAR_FOR_BUILD}"
GNU_TOOLS_OPTS="$GNU_TOOLS_OPTS CC=${CC_FOR_BUILD} LD=${LD_FOR_BUILD}
AR=${AR_FOR_BUILD} NM=${NM_FOR_BUILD} STRIP=${STRIP_FOR_BUILD}"
GNU_TOOLS_OPTS="$GNU_TOOLS_OPTS OBJCOPY=${OBJCOPY_FOR_BUILD}
OBJDUMP=${OBJDUMP_FOR_BUILD} READELF=${READELF_FOR_BUILD}"

That works - means passes all binaries from GNU binutils v2.35.2 to my
make-line.

Please NOTE that I had to symlink GNU AS v2.35.2 as I saw too late I
was using Debian's GNU AS v2.35.1 within my last builds.

AFAICS there is no more AS= assignment in the top-level Makefile.
How can I say: "Please use a different ASsembler?"

[ LDD ]

When I inspect with ldd (here: GNU AS v2.35.2):

# ldd /opt/binutils/bin/as
       linux-vdso.so.1 (0x00007ffc7f4d6000)
       libopcodes-2.35.2.so =>
/opt/binutils-2.35.2/lib/libopcodes-2.35.2.so (0x00007f11f3bcc000)
       libbfd-2.35.2.so => /opt/binutils-2.35.2/lib/libbfd-2.35.2.so
(0x00007f11f3a8b000)
       libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f11f3a44000)
       libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f11f387f000)
       libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f11f3879000)
       /lib64/ld-linux-x86-64.so.2 (0x00007f11f3de3000)

So GNU AS v2.35.2 is loading from the correct places.

Is the symlink in /opt directory a problem?
binutils -> binutils-2.35.2

Can someone comment and give me a hint?

Thanks in advance.

Regards,
- Sedat -

             reply	other threads:[~2021-02-05 11:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05 10:56 Sedat Dilek [this message]
2021-02-05 21:36 ` Using GNU AS from a selfmade binutils v2.35.2 Nathan Chancellor
2021-02-05 21:44   ` Nick Desaulniers
2021-02-05 21:53     ` Sedat Dilek
2021-02-05 21:55     ` Nathan Chancellor
2021-02-05 22:05       ` Nick Desaulniers
2021-02-06 12:41 ` Sedat Dilek

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=CA+icZUUjb_71mWwWFMYN_OPZir2vStLq1kDY1O+JCFjtmEEBjA@mail.gmail.com \
    --to=sedat.dilek@gmail.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /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.