[U-Boot] Compile v2017.03 on a system where Python 3 is default

Stefan Agner stefan at agner.ch
Wed Mar 29 00:30:37 UTC 2017


Hi,

When I try to compile U-Boot on my Arch Linux system I get the following
error:

LDFLAGS="" python ./lib/libfdt/setup.py \
        "-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer    -include
./include/libfdt_env.h -idirafterinclude -idirafter./arch/arm/include
-I./lib/libfdt -I./tools -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
-D_GNU_SOURCE " lib/libfdt/fdt.c lib/libfdt/fdt_ro.c lib/libfdt/fdt_rw.c
lib/libfdt/fdt_strerror.c lib/libfdt/fdt_wip.c lib/libfdt/fdt_region.c
lib/libfdt/fdt_sw.c tools/libfdt_wrap.c
mv _libfdt.so tools/_libfdt.so
mv: cannot stat '_libfdt.so': No such file or directory
make[1]: *** [tools/Makefile:124: tools/_libfdt.so] Error 1
make: *** [Makefile:1229: tools] Error 2


As far as I can tell the issue is that python defaults on my system to
python 3:
$ python --version
Python 3.6.0

I can fix the issue by explicitly ask for python2, not sure if that is
the proper way to fix this though:

diff --git a/tools/Makefile b/tools/Makefile
index 1c840d7ae2..c5e422edf9 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -120,7 +120,7 @@ _libfdt.so-sharedobjs += $(LIBFDT_OBJS)
 libfdt:

 tools/_libfdt.so: $(patsubst %.o,%.c,$(LIBFDT_OBJS))
tools/libfdt_wrap.c
-       LDFLAGS="$(HOSTLDFLAGS)" python $(srctree)/lib/libfdt/setup.py \
+       LDFLAGS="$(HOSTLDFLAGS)" python2 $(srctree)/lib/libfdt/setup.py
\
                "$(_hostc_flags)" $^
        mv _libfdt.so $@


It works, but with warnings:
LDFLAGS="" python2 ./lib/libfdt/setup.py \
        "-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer    -include
./include/libfdt_env.h -idirafterinclude -idirafter./arch/arm/include
-I./lib/libfdt -I./tools -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
-D_GNU_SOURCE " lib/libfdt/fdt.c lib/libfdt/fdt_ro.c lib/libfdt/fdt_rw.c
lib/libfdt/fdt_strerror.c lib/libfdt/fdt_wip.c lib/libfdt/fdt_region.c
lib/libfdt/fdt_sw.c tools/libfdt_wrap.c
In file included from /usr/include/python2.7/Python.h:8:0,
                 from tools/libfdt_wrap.c:149:
/usr/include/python2.7/pyconfig.h:1190:0: warning: "_POSIX_C_SOURCE"
redefined
 #define _POSIX_C_SOURCE 200112L

In file included from /usr/include/stdint.h:25:0,
                 from
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/include/stdint.h:9,
                 from ././include/compiler.h:19,
                 from ././include/libfdt_env.h:12,
                 from <command-line>:0:
/usr/include/features.h:225:0: note: this is the location of the
previous definition
 # define _POSIX_C_SOURCE 200809L

In file included from /usr/include/python2.7/Python.h:8:0,
                 from tools/libfdt_wrap.c:149:
/usr/include/python2.7/pyconfig.h:1212:0: warning: "_XOPEN_SOURCE"
redefined
 #define _XOPEN_SOURCE 600

In file included from /usr/include/stdint.h:25:0,
                 from
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/include/stdint.h:9,
                 from ././include/compiler.h:19,
                 from ././include/libfdt_env.h:12,
                 from <command-line>:0:
/usr/include/features.h:166:0: note: this is the location of the
previous definition
 # define _XOPEN_SOURCE 700

mv _libfdt.so tools/_libfdt.so
  HOSTCC  tools/proftool
...


--
Stefan


More information about the U-Boot mailing list