<div dir="ltr">Mark,<div><br></div><div>I ran the same command, including the offending PYTHONPATH, from the shell without error. Any reason why that would work, despite it not working from within the Makefile? I was thinking it was another environment variable that was causing the issue (one that's not set in my bash environment by default). My $PATH didn't have python-native so I called it using an absolute path, but otherwise it's the same command run from the Makefile (parsed, of course):</div><div><br></div><div><div>bash$ _PYTHON_PROJECT_BASE=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build _PYTHON_HOST_PLATFORM=linux2-x86_64 PYTHONPATH=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build/build/lib.linux2-x86_64-2.7:/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Lib:/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Lib/plat-linux2 /projects/yocto-git/build/tmp/sysroots/x86_64-linux/usr/bin/python-native/python2.7 -S -m sysconfig --generate-posix-vars</div><div>bash$ ls pybuilddir.txt</div><div>pybuilddir.txt</div></div><div><br></div><div>Maybe I'm missing something.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 25, 2015 at 4:38 PM, Mark Hatle <span dir="ltr"><<a href="mailto:mark.hatle@windriver.com" target="_blank">mark.hatle@windriver.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11/25/15 10:11 AM, Michael Habibi wrote:<br>
> Well, I'm wrong yet again. A 'which python2.7' shows that it's pointing to a<br>
> native version of Python:<br>
><br>
</span>> *| which python2.7*<br>
> *|<br>
> /projects/yocto-git/build/tmp/sysroots/x86_64-linux/usr/bin/python-native/python2.7*<br>
<span class="">> |<br>
> _PYTHON_PROJECT_BASE=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build<br>
> _PYTHON_HOST_PLATFORM=linux2-x86_64<br>
> PYTHONPATH=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build/build/lib.linux2-x86_64-2.7:/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Lib:/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Lib/plat-linux2<br>
> python2.7 -S -m sysconfig --generate-posix-vars ;\<br>
> |  Â  Â  Â if test $? -ne 0 ; then \<br>
> |  Â  Â  Â  Â  Â  Â  Â echo "generate-posix-vars failed" ; \<br>
> |  Â  Â  Â  Â  Â  Â  Â rm -f ./pybuilddir.txt ; \<br>
> |  Â  Â  Â  Â  Â  Â  Â exit 1 ; \<br>
> |  Â  Â  Â fi<br>
> | Illegal instruction (core dumped)<br>
> | make: *** [sharedmods] Error 132<br>
><br>
> I guess one of the environmental variables being passed in is screwing up what<br>
> it's doing. Unfortunately I don't know enough about the inner workings of Python<br>
> to be of much help moving forward. I gave it my best shot!<br>
<br>
</span>The problem I tracked down was:<br>
<br>
PYTHONPATH=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build/build/lib.linux2-x86_64-2.7<br>
<br>
This is full of .so objects when loaded cause the illegal instruction.<br>
<br>
I came up with a patch that I thought was going to fix it, but it's triggered<br>
other failures.<br>
<br>
<a href="http://lists.openembedded.org/pipermail/openembedded-core/2015-November/113341.html" rel="noreferrer" target="_blank">http://lists.openembedded.org/pipermail/openembedded-core/2015-November/113341.html</a><br>
<br>
Just to be clear.. this does NOT work properly in many cases.  But might give<br>
you or someone else a clue as to how to possibly fix it.<br>
<br>
--Mark<br>
<span class=""><br>
><br>
> On Wed, Nov 25, 2015 at 10:01 AM, Michael Habibi <<a href="mailto:mikehabibi@gmail.com">mikehabibi@gmail.com</a><br>
</span><span class="">> <mailto:<a href="mailto:mikehabibi@gmail.com">mikehabibi@gmail.com</a>>> wrote:<br>
><br>
>  Â  Â Ah sorry, I misspoke. I walked through the Makefile and configure scripts a<br>
>  Â  Â bit more, and $(PYTHON_FOR_BUILD) should in fact be a host version of<br>
>  Â  Â Python. It seems it's not being configured correctly. Either the path is<br>
>  Â  Â setup wrong and python2.7 is not pointing to the right version, or python2.7<br>
>  Â  Â needs to be pointing to the absolute path instead of relying on $PATH.<br>
><br>
><br>
><br>
><br>
>  Â  Â On Wed, Nov 25, 2015 at 9:45 AM, Michael Habibi <<a href="mailto:mikehabibi@gmail.com">mikehabibi@gmail.com</a><br>
</span><div><div class="h5">>  Â  Â <mailto:<a href="mailto:mikehabibi@gmail.com">mikehabibi@gmail.com</a>>> wrote:<br>
><br>
>  Â  Â  Â  Â For what it's worth, this is the offending portion of Makefile.pre:452:<br>
><br>
>  Â  Â  Â  Â # Create build directory and generate the sysconfig build-time data there.<br>
>  Â  Â  Â  Â # pybuilddir.txt contains the name of the build dir and is used for<br>
>  Â  Â  Â  Â # sys.path fixup -- see Modules/getpath.c.<br>
>  Â  Â  Â  Â # Since this step runs before shared modules are built, try to avoid<br>
>  Â  Â  Â  Â bootstrap<br>
>  Â  Â  Â  Â # problems by creating a dummy pybuilddir.txt just to allow interpreter<br>
>  Â  Â  Â  Â # initialization to succeed.  It will be overwritten by generate-posix-vars<br>
>  Â  Â  Â  Â # or removed in case of failure.<br>
>  Â  Â  Â  Â pybuilddir.txt: $(BUILDPYTHON)<br>
>  Â  Â  Â  Â â†’ @echo "none" > ./pybuilddir.txt<br>
>  Â  Â  Â  Â â†’ $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\<br>
>  Â  Â  Â  Â â†’ if test $$? -ne 0 ; then \<br>
>  Â  Â  Â  Â â†’ â†’ echo "generate-posix-vars failed" ; \<br>
>  Â  Â  Â  Â â†’ â†’ rm -f ./pybuilddir.txt ; \<br>
>  Â  Â  Â  Â â†’ â†’ exit 1 ; \<br>
>  Â  Â  Â  Â â†’ fi<br>
><br>
>  Â  Â  Â  Â I don't know enough about the Python build to understand what it's<br>
>  Â  Â  Â  Â trying to do, but perhaps replacing PYTHON_FOR_BUILD with HOSTPYTHON may<br>
>  Â  Â  Â  Â be acceptable?<br>
><br>
>  Â  Â  Â  Â I'm surprised this seems to work for other people, since this should be<br>
>  Â  Â  Â  Â failing for anyone using Python on a target platform different from<br>
>  Â  Â  Â  Â their host.<br>
><br>
>  Â  Â  Â  Â On Wed, Nov 25, 2015 at 9:02 AM, Mark Hatle <<a href="mailto:mark.hatle@windriver.com">mark.hatle@windriver.com</a><br>
</div></div><div><div class="h5">>  Â  Â  Â  Â <mailto:<a href="mailto:mark.hatle@windriver.com">mark.hatle@windriver.com</a>>> wrote:<br>
><br>
>  Â  Â  Â  Â  Â  Â On 11/24/15 3:23 PM, Mark Hatle wrote:<br>
>  Â  Â  Â  Â  Â  Â > My guess is that there is a bug in the python integration where<br>
>  Â  Â  Â  Â  Â  Â it's not<br>
>  Â  Â  Â  Â  Â  Â > realizing the host and target are different systems, so it's<br>
>  Â  Â  Â  Â  Â  Â trying to run a<br>
>  Â  Â  Â  Â  Â  Â > target program on your host.  Your host isn't haswell, so...<br>
>  Â  Â  Â  Â  Â  Â Illegal Instruction<br>
>  Â  Â  Â  Â  Â  Â > -- and the system stops.<br>
><br>
>  Â  Â  Â  Â  Â  Â Just an FYI, I hit the same problem today.  I suspect it is the host<br>
>  Â  Â  Â  Â  Â  Â trying to<br>
>  Â  Â  Â  Â  Â  Â run target software and I'm looking into it.<br>
><br>
>  Â  Â  Â  Â  Â  Â --Mark<br>
><br>
>  Â  Â  Â  Â  Â  Â > The alternative would be something is running QEMU to execute a<br>
>  Â  Â  Â  Â  Â  Â target binary<br>
>  Â  Â  Â  Â  Â  Â > and QEMU doesn't have instruction support -- but that doesn't look<br>
>  Â  Â  Â  Â  Â  Â like the case<br>
>  Â  Â  Â  Â  Â  Â > here.<br>
>  Â  Â  Â  Â  Â  Â ><br>
>  Â  Â  Â  Â  Â  Â > --Mark<br>
>  Â  Â  Â  Â  Â  Â ><br>
>  Â  Â  Â  Â  Â  Â > On 11/24/15 3:06 PM, Michael Habibi wrote:<br>
>  Â  Â  Â  Â  Â  Â >> All,<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> I added a new machine definition with tuning parameters for haswell<br>
>  Â  Â  Â  Â  Â  Â >> microarchitectures (basically just duplicated corei7 but tuned it<br>
>  Â  Â  Â  Â  Â  Â for haswell).<br>
>  Â  Â  Â  Â  Â  Â >> This seems to work correctly, but failed when running do_install<br>
>  Â  Â  Â  Â  Â  Â for python<br>
>  Â  Â  Â  Â  Â  Â >> toward the end of the build process. I am running with the Yocto<br>
>  Â  Â  Â  Â  Â  Â 2.0 framework,<br>
>  Â  Â  Â  Â  Â  Â >> with very minimal changes to create a new distribution and<br>
>  Â  Â  Â  Â  Â  Â machine for our<br>
>  Â  Â  Â  Â  Â  Â >> custom embedded device. Note I had this distro configuration<br>
>  Â  Â  Â  Â  Â  Â working before, and<br>
>  Â  Â  Â  Â  Â  Â >> the only difference is I added a new machine with this tuning.<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> I believe the issue is because, as part of the do_install step<br>
>  Â  Â  Â  Â  Â  Â for Python, it<br>
>  Â  Â  Â  Â  Â  Â >> attempts to run python on the local host, despite being<br>
>  Â  Â  Â  Â  Â  Â cross-compiled. However,<br>
>  Â  Â  Â  Â  Â  Â >> it is tuned for a processor that my host machine doesn't run, so<br>
>  Â  Â  Â  Â  Â  Â I get an<br>
>  Â  Â  Â  Â  Â  Â >> instruction exception.<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> Did I do something weird? I figure python would be configured for<br>
>  Â  Â  Â  Â  Â  Â >> cross-compiling and therefore wouldn't try to run the target<br>
>  Â  Â  Â  Â  Â  Â version on the<br>
>  Â  Â  Â  Â  Â  Â >> host, even for sanity tests. Here is the output of the failure:<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> $ tail -20<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â /projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/temp/log.do_install.17258<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> x86_64-diags-linux-ar rc libpython2.7.a Modules/threadmodule.o<br>
>  Â  Â  Â  Â  Â  Â >>  Modules/signalmodule.o  Modules/posixmodule.o  Modules/errnomodule.o<br>
>  Â  Â  Â  Â  Â  Â >>  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o<br>
>  Â  Â  Â  Â  Â  Â >>  Modules/_weakref.o  Modules/zipimport.o  Modules/symtablemodule.o<br>
>  Â  Â  Â  Â  Â  Â >>  Modules/md5module.o Modules/md5.o  Modules/xxsubtype.o<br>
>  Â  Â  Â  Â  Â  Â >> x86_64-diags-linux-ranlib libpython2.7.a<br>
>  Â  Â  Â  Â  Â  Â >> Modules/posixmodule.o: In function `posix_tmpnam':<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â /projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Modules/posixmodule.c:7575:<br>
>  Â  Â  Â  Â  Â  Â >> warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'<br>
>  Â  Â  Â  Â  Â  Â >> Modules/posixmodule.o: In function `posix_tempnam':<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â /projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Modules/posixmodule.c:7522:<br>
>  Â  Â  Â  Â  Â  Â >> warning: the use of `tempnam' is dangerous, better use `mkstemp'<br>
>  Â  Â  Â  Â  Â  Â >> x86_64-diags-linux-gcc  -m64 -march=haswell -mtune=haswell<br>
>  Â  Â  Â  Â  Â  Â -mfpmath=sse -mavx2<br>
>  Â  Â  Â  Â  Â  Â >> --sysroot=/projects/yocto-git/build/tmp/sysroots/continental -Wl,-O1<br>
>  Â  Â  Â  Â  Â  Â >> -Wl,--hash-style=gnu -Wl,--as-needed -Xlinker -export-dynamic -o<br>
>  Â  Â  Â  Â  Â  Â python \<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Modules/python.o \<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â -L. -lpython2.7 -lpthread -ldl  -lpthread<br>
>  Â  Â  Â  Â  Â  Â -lutil  Â -lm<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â _PYTHON_PROJECT_BASE=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build<br>
>  Â  Â  Â  Â  Â  Â >> _PYTHON_HOST_PLATFORM=linux2-x86_64<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â PYTHONPATH=/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/build/build/lib.linux2-x86_64-2.7:/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Lib:/projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/Python-2.7.9/Lib/plat-linux2<br>
>  Â  Â  Â  Â  Â  Â >> python2.7 -S -m sysconfig --generate-posix-vars ;\<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â if test $? -ne 0 ; then \<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â  Â  Â  Â  Â echo "generate-posix-vars failed" ; \<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â  Â  Â  Â  Â rm -f ./pybuilddir.txt ; \<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â  Â  Â  Â  Â exit 1 ; \<br>
>  Â  Â  Â  Â  Â  Â >>  Â  Â  Â  Â fi<br>
>  Â  Â  Â  Â  Â  Â >> Illegal instruction (core dumped)<br>
>  Â  Â  Â  Â  Â  Â >> make: *** [sharedmods] Error 132<br>
>  Â  Â  Â  Â  Â  Â >> WARNING: exit code 1 from a shell command.<br>
>  Â  Â  Â  Â  Â  Â >> ERROR: oe_runmake failed<br>
>  Â  Â  Â  Â  Â  Â >> ERROR: Function failed: do_install (log file is located at<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â /projects/yocto-git/build/tmp/work/haswell-diags-linux/python/2.7.9-r1/temp/log.do_install.17258)<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> Here is my tune-haswell.inc (ignore some copy/paste comment<br>
>  Â  Â  Â  Â  Â  Â issues right now =):<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> # Settings for the GCC(1) cpu-type "haswell":<br>
>  Â  Â  Â  Â  Â  Â >> #<br>
>  Â  Â  Â  Â  Â  Â >> #  Â  Â Intel Core i7 CPU with 64-bit extensions, MOVBE, MMX, SSE,<br>
>  Â  Â  Â  Â  Â  Â SSE2, SSE3,·<br>
>  Â  Â  Â  Â  Â  Â >> #  Â  Â SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AVX2, AES, PCLMUL,<br>
>  Â  Â  Â  Â  Â  Â FSGSBASE,<br>
>  Â  Â  Â  Â  Â  Â >> #  Â  Â RDRND, FMA, BMI, BMI2 and F16C instruction set support.<br>
>  Â  Â  Â  Â  Â  Â >> #<br>
>  Â  Â  Â  Â  Â  Â >> # This tune is recommended for Intel Nehalem and Silvermont (e.g.<br>
>  Â  Â  Â  Â  Â  Â Bay Trail) CPUs<br>
>  Â  Â  Â  Â  Â  Â >> # (and beyond).<br>
>  Â  Â  Â  Â  Â  Â >> #<br>
>  Â  Â  Â  Â  Â  Â >> DEFAULTTUNE ?= "haswell"<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> # Pull in the previous tune in to pull in PACKAGE_EXTRA_ARCHS<br>
>  Â  Â  Â  Â  Â  Â >> require conf/machine/include/tune-corei7.inc<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> # Extra tune features<br>
>  Â  Â  Â  Â  Â  Â >> TUNEVALID[haswell] = "Enable haswell specific processor<br>
>  Â  Â  Â  Â  Â  Â optimizations"<br>
>  Â  Â  Â  Â  Â  Â >> TUNE_CCARGS .= "${@bb.utils.contains("TUNE_FEATURES", "haswell", "<br>
>  Â  Â  Â  Â  Â  Â >> -march=haswell -mtune=haswell -mfpmath=sse -mavx2", "", d)}"<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >> # Extra tune selections<br>
>  Â  Â  Â  Â  Â  Â >> AVAILTUNES += "haswell"<br>
>  Â  Â  Â  Â  Â  Â >> TUNE_FEATURES_tune-haswell = "${TUNE_FEATURES_tune-x86-64} haswell"<br>
>  Â  Â  Â  Â  Â  Â >> BASE_LIB_tune-haswell = "lib"<br>
>  Â  Â  Â  Â  Â  Â >> TUNE_PKGARCH_tune-haswell = "haswell"<br>
>  Â  Â  Â  Â  Â  Â >> PACKAGE_EXTRA_ARCHS_tune-haswell =<br>
>  Â  Â  Â  Â  Â  Â "${PACKAGE_EXTRA_ARCHS_tune-corei7} haswell"<br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â >><br>
>  Â  Â  Â  Â  Â  Â ><br>
><br>
>  Â  Â  Â  Â  Â  Â --<br>
>  Â  Â  Â  Â  Â  Â _______________________________________________<br>
>  Â  Â  Â  Â  Â  Â yocto mailing list<br>
</div></div>>  Â  Â  Â  Â  Â  Â <a href="mailto:yocto@yoctoproject.org">yocto@yoctoproject.org</a> <mailto:<a href="mailto:yocto@yoctoproject.org">yocto@yoctoproject.org</a>><br>
>  Â  Â  Â  Â  Â  Â <a href="https://lists.yoctoproject.org/listinfo/yocto" rel="noreferrer" target="_blank">https://lists.yoctoproject.org/listinfo/yocto</a><br>
><br>
><br>
><br>
><br>
<br>
</blockquote></div><br></div>