2024-02-01 11:34:40

by Anders Roxell

[permalink] [raw]
Subject: Perf not able to cross compile

Hey,

I'm trying to cross compile perf ARCH=arm64 on my x86_64 host from
linus tree [1], branch master.


This is the failue I see, full log [2]:

..
CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/elf.o
CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/features.o
cc1: error: ‘-fcf-protection=full’ is not supported for this target
error: command '/usr/local/bin/sccache' failed with exit code 1
cp: cannot stat
'/home/tuxbuild/.cache/tuxmake/builds/1/build/python_ext_build/lib/perf*.so':
No such file or directory
make[2]: *** [Makefile.perf:678:
/home/tuxbuild/.cache/tuxmake/builds/1/build/python/perf.cpython-311-x86_64-linux-gnu.so]
Error 1
make[2]: *** Waiting for unfinished jobs....
LD /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/libbpf-in.o
LINK /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/libbpf.a
make[1]: *** [Makefile.perf:261: sub-make] Error 2
make: *** [Makefile:70: all] Error 2

Running 'x86_64-linux-gnu-python3-config --cflags' I see
'-fcf-protection' in the output and this happens when I'm building
cross compile arm64 on my x86_64 host machine. Building on an arm64
host works. cross compile x86_64 on my x86_64 host works too.

I have 'aarch64-linux-gnu-python3-config' installed but that isn't used.

$ x86_64-linux-gnu-python3-config --cflags
-I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
-fstack-protector-strong -fstack-clash-protection -Wformat
-Werror=format-security -fcf-protection -DNDEBUG -g -fwrapv -O2 -Wall
$ aarch64-linux-gnu-python3-config --cflags
-I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
-fstack-protector-strong -fstack-clash-protection -Wformat
-Werror=format-security -mbranch-protection=standard -DNDEBUG -g
-fwrapv -O2 -Wall

I tried to set PYTHON and PYTHON_CONFIG too, but didn't work.

It doesn't try to use $(CROSS_COMPILE)python3-config, any idea how to
use the correct config?

Cheers,
Anders
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[2] https://storage.tuxsuite.com/public/linaro/lkft/builds/2bc6x6cISHzG9Jgo0oAVv2OgLOG/build.log


2024-02-01 11:52:59

by James Clark

[permalink] [raw]
Subject: Re: Perf not able to cross compile



On 01/02/2024 11:32, Anders Roxell wrote:
> Hey,
>
> I'm trying to cross compile perf ARCH=arm64 on my x86_64 host from
> linus tree [1], branch master.
>
>
> This is the failue I see, full log [2]:
>
> ...
> CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/elf.o
> CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/features.o
> cc1: error: ‘-fcf-protection=full’ is not supported for this target
> error: command '/usr/local/bin/sccache' failed with exit code 1
> cp: cannot stat
> '/home/tuxbuild/.cache/tuxmake/builds/1/build/python_ext_build/lib/perf*.so':
> No such file or directory
> make[2]: *** [Makefile.perf:678:
> /home/tuxbuild/.cache/tuxmake/builds/1/build/python/perf.cpython-311-x86_64-linux-gnu.so]
> Error 1
> make[2]: *** Waiting for unfinished jobs....
> LD /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/libbpf-in.o
> LINK /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/libbpf.a
> make[1]: *** [Makefile.perf:261: sub-make] Error 2
> make: *** [Makefile:70: all] Error 2
>
> Running 'x86_64-linux-gnu-python3-config --cflags' I see
> '-fcf-protection' in the output and this happens when I'm building
> cross compile arm64 on my x86_64 host machine. Building on an arm64
> host works. cross compile x86_64 on my x86_64 host works too.
>
> I have 'aarch64-linux-gnu-python3-config' installed but that isn't used.
>
> $ x86_64-linux-gnu-python3-config --cflags
> -I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
> -fstack-protector-strong -fstack-clash-protection -Wformat
> -Werror=format-security -fcf-protection -DNDEBUG -g -fwrapv -O2 -Wall
> $ aarch64-linux-gnu-python3-config --cflags
> -I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
> -fstack-protector-strong -fstack-clash-protection -Wformat
> -Werror=format-security -mbranch-protection=standard -DNDEBUG -g
> -fwrapv -O2 -Wall
>
> I tried to set PYTHON and PYTHON_CONFIG too, but didn't work.
>
> It doesn't try to use $(CROSS_COMPILE)python3-config, any idea how to
> use the correct config?
>
> Cheers,
> Anders
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> [2] https://storage.tuxsuite.com/public/linaro/lkft/builds/2bc6x6cISHzG9Jgo0oAVv2OgLOG/build.log


Hi Anders,

I see something similar but in the end it works. Despite the name, I
also get perf.cpython-311-x86_64-linux-gnu.so generated in my build, but
it's actually an arm binary.

For me I'm using python3.10, and the x86 config options don't include
-fcf-protection which is probably why it can compile successfully with
the arm compiler.

It looks like your assumption is correct and it's not using
$(CROSS_COMPILE)python3-config but just python3-config. The answer to
how to fix it is probably to start hacking at the makefiles, if PYTHON
and PYTHON_CONFIG don't work either.

James

2024-02-01 19:21:25

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: Perf not able to cross compile

Em Thu, Feb 01, 2024 at 12:32:09PM +0100, Anders Roxell escreveu:
> Hey,
>
> I'm trying to cross compile perf ARCH=arm64 on my x86_64 host from
> linus tree [1], branch master.
>
>
> This is the failue I see, full log [2]:
>
> ...
> CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/elf.o
> CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/features.o
> cc1: error: ‘-fcf-protection=full’ is not supported for this target
> error: command '/usr/local/bin/sccache' failed with exit code 1

We have some checks to deal with unknown options that came from python,
perl config, but it seems in your case there is something that is not
being covered, worth of further investigation.

Can you simply first try disabling python support? Look at
tools/perf/Makefile.perf, first trying with NO_LIBPYTHON=1 to your
make command line?

- Arnaldo

> cp: cannot stat
> '/home/tuxbuild/.cache/tuxmake/builds/1/build/python_ext_build/lib/perf*.so':
> No such file or directory
> make[2]: *** [Makefile.perf:678:
> /home/tuxbuild/.cache/tuxmake/builds/1/build/python/perf.cpython-311-x86_64-linux-gnu.so]
> Error 1
> make[2]: *** Waiting for unfinished jobs....
> LD /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/libbpf-in.o
> LINK /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/libbpf.a
> make[1]: *** [Makefile.perf:261: sub-make] Error 2
> make: *** [Makefile:70: all] Error 2
>
> Running 'x86_64-linux-gnu-python3-config --cflags' I see
> '-fcf-protection' in the output and this happens when I'm building
> cross compile arm64 on my x86_64 host machine. Building on an arm64
> host works. cross compile x86_64 on my x86_64 host works too.
>
> I have 'aarch64-linux-gnu-python3-config' installed but that isn't used.
>
> $ x86_64-linux-gnu-python3-config --cflags
> -I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
> -fstack-protector-strong -fstack-clash-protection -Wformat
> -Werror=format-security -fcf-protection -DNDEBUG -g -fwrapv -O2 -Wall
> $ aarch64-linux-gnu-python3-config --cflags
> -I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
> -fstack-protector-strong -fstack-clash-protection -Wformat
> -Werror=format-security -mbranch-protection=standard -DNDEBUG -g
> -fwrapv -O2 -Wall
>
> I tried to set PYTHON and PYTHON_CONFIG too, but didn't work.
>
> It doesn't try to use $(CROSS_COMPILE)python3-config, any idea how to
> use the correct config?
>
> Cheers,
> Anders
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> [2] https://storage.tuxsuite.com/public/linaro/lkft/builds/2bc6x6cISHzG9Jgo0oAVv2OgLOG/build.log

--

- Arnaldo

2024-02-01 19:22:09

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: Perf not able to cross compile

Em Thu, Feb 01, 2024 at 11:52:07AM +0000, James Clark escreveu:
>
>
> On 01/02/2024 11:32, Anders Roxell wrote:
> > Hey,
> >
> > I'm trying to cross compile perf ARCH=arm64 on my x86_64 host from
> > linus tree [1], branch master.
> >
> >
> > This is the failue I see, full log [2]:
> >
> > ...
> > CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/elf.o
> > CC /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/features.o
> > cc1: error: ‘-fcf-protection=full’ is not supported for this target
> > error: command '/usr/local/bin/sccache' failed with exit code 1
> > cp: cannot stat
> > '/home/tuxbuild/.cache/tuxmake/builds/1/build/python_ext_build/lib/perf*.so':
> > No such file or directory
> > make[2]: *** [Makefile.perf:678:
> > /home/tuxbuild/.cache/tuxmake/builds/1/build/python/perf.cpython-311-x86_64-linux-gnu.so]
> > Error 1
> > make[2]: *** Waiting for unfinished jobs....
> > LD /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/staticobjs/libbpf-in.o
> > LINK /home/tuxbuild/.cache/tuxmake/builds/1/build/libbpf/libbpf.a
> > make[1]: *** [Makefile.perf:261: sub-make] Error 2
> > make: *** [Makefile:70: all] Error 2
> >
> > Running 'x86_64-linux-gnu-python3-config --cflags' I see
> > '-fcf-protection' in the output and this happens when I'm building
> > cross compile arm64 on my x86_64 host machine. Building on an arm64
> > host works. cross compile x86_64 on my x86_64 host works too.
> >
> > I have 'aarch64-linux-gnu-python3-config' installed but that isn't used.
> >
> > $ x86_64-linux-gnu-python3-config --cflags
> > -I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
> > -fstack-protector-strong -fstack-clash-protection -Wformat
> > -Werror=format-security -fcf-protection -DNDEBUG -g -fwrapv -O2 -Wall
> > $ aarch64-linux-gnu-python3-config --cflags
> > -I/usr/include/python3.11 -I/usr/include/python3.11 -Wsign-compare -g
> > -fstack-protector-strong -fstack-clash-protection -Wformat
> > -Werror=format-security -mbranch-protection=standard -DNDEBUG -g
> > -fwrapv -O2 -Wall
> >
> > I tried to set PYTHON and PYTHON_CONFIG too, but didn't work.
> >
> > It doesn't try to use $(CROSS_COMPILE)python3-config, any idea how to
> > use the correct config?
> >
> > Cheers,
> > Anders
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > [2] https://storage.tuxsuite.com/public/linaro/lkft/builds/2bc6x6cISHzG9Jgo0oAVv2OgLOG/build.log
>
>
> Hi Anders,
>
> I see something similar but in the end it works. Despite the name, I
> also get perf.cpython-311-x86_64-linux-gnu.so generated in my build, but
> it's actually an arm binary.
>
> For me I'm using python3.10, and the x86 config options don't include
> -fcf-protection which is probably why it can compile successfully with
> the arm compiler.
>
> It looks like your assumption is correct and it's not using
> $(CROSS_COMPILE)python3-config but just python3-config. The answer to
> how to fix it is probably to start hacking at the makefiles, if PYTHON
> and PYTHON_CONFIG don't work either.

Right, that seems like a good direction in trying to fix this.

- Arnaldo