From: Stefan Agner Date: Thu, 30 Mar 2017 11:55:22 -0700 Subject: [U-Boot] Compile v2017.03 on a system where Python 3 is default In-Reply-To: <20170330175425.GA1507@gmail.com> References: <8abb0873e2fb0becb73822332eb2f814@agner.ch> <20170330175425.GA1507@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 2017-03-30 10:54, Jelle van der Waa wrote: > On 03/28/17 at 05:30pm, Stefan Agner wrote: >> Hi, >> >> When I try to compile U-Boot on my Arch Linux system I get the following > > Python 3 needs some more TLC, I've been hacking on making binman work > out of the box with Python 3 (and retaining Python 2 compatibility). But > haven't been able to get it working yet. [1] > > [1] https://github.com/jelly/u-boot/commits/binman_py3 Hm, not sure but I think my issue is not related to that. binman asks for Python 2 by default using shebang: 11:48 $ head tools/binman/binman #!/usr/bin/env python2 ... And the way we call binman respects shebang: # binman # --------------------------------------------------------------------------- quiet_cmd_binman = BINMAN $@ cmd_binman = $(srctree)/tools/binman/binman -d u-boot.dtb -O . \ -I . -I $(srctree)/board/$(BOARDDIR) $< I do have Python 2 installed, so binman gets executed with Python 2 and works well here... Its just that "python" symlinks to python3, which seems to be an issue for ./lib/libfdt/setup.py. In the ./lib/libfdt/setup.py case the Makefile calls that script as an argument to the explicitly called python interpreter: 11:56 $ grep -C 2 -e setup.py tools/Makefile tools/_libfdt.so: $(patsubst %.o,%.c,$(LIBFDT_OBJS)) tools/libfdt_wrap.c LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= python $(srctree)/lib/libfdt/setup.py \ "$(_hostc_flags)" $^ mv _libfdt.so $@ Anyway, it seems that ./lib/libfdt/setup.py actually works fine with Python 3 when using the --force argument, which is what we want in that case, imho... So this fix resolves the issue for me: https://patchwork.ozlabs.org/patch/744927/ -- Stefan > >> 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 :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 :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 >> _______________________________________________ >> U-Boot mailing list >> U-Boot at lists.denx.de >> https://lists.denx.de/listinfo/u-boot