8000 mpy-cross/Makefile: Also undefine MICROPY_FORCE_32BIT and CROSS_COMPILE. by pfalcon · Pull Request #3987 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

mpy-cross/Makefile: Also undefine MICROPY_FORCE_32BIT and CROSS_COMPILE. #3987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

pfalcon
Copy link
Contributor
@pfalcon pfalcon commented Jul 29, 2018

mpy-cross is a host, not target binary. It should not be build with the
target compiler, compiler options and other settings. For example,

If someone currently tries to build from pristine checkout the unix port
with the following command:

make CROSS_COMPILE=arm-linux-gnueabihf-

then mpy-cross will be built with arm-linux-gnueabihf-gcc and of course
won't run on the host, leading to overall build failure.

This situation was worked around for some options in 1d8c3f4, so add
MICROPY_FORCE_32BIT and CROSS_COMPILE to that set too.

mpy-cross is a host, not target binary. It should not be build with the
target compiler, compiler options and other settings. For example,

If someone currently tries to build from pristine checkout the unix port
with the following command:

    make CROSS_COMPILE=arm-linux-gnueabihf-

then mpy-cross will be built with arm-linux-gnueabihf-gcc and of course
won't run on the host, leading to overall build failure.

This situation was worked around for some options in 1d8c3f4, so add
MICROPY_FORCE_32BIT and CROSS_COMPILE to that set too.
@pfalcon
Copy link
Contributor Author
pfalcon commented Jul 29, 2018

#3255 keeps giving bad surprises.

Note that workaround with "override undefine" is pretty poor. How it should work is:

  1. When mpy-cross is built recursivelt as a dependency of some port, it should be built with "default host compiler".
  2. But if some cd's into mpy-cross/, and runs make CROSS_COMPILE=arm-linux-gnueabihf-, they should be able to build mpy-cross crosscompiled for arm. Currently that's not possible.

The right place to do that would be:

$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/ports/windows/fmode.c
       $(Q)$(MAKE) -C $(TOP)/mpy-cross

That invocation of $(MAKE) should not get any vars passed to the top-level make on the command line. https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html says that MAKEFLAGS= should do the trick, but:

-       $(Q)$(MAKE) -C $(TOP)/mpy-cross
+       $(Q)$(MAKE) -C $(TOP)/mpy-cross MAKEFLAGS= MAKEOVERRIDES=

didn't work as expected for me.

But

-       $(Q)$(MAKE) -C $(TOP)/mpy-cross
+       $(Q)$(MAKE) -C $(TOP)/mpy-cross MICROPY_FORCE_32BIT=0

of course works, though a bunch of options would need to be passed.

Another way is to explicitly define HOST_CC, HOST_CFLAGS, HOST_CROSS_COMPILE, etc. and use that in mpy-cross/Makefile.

@pfalcon
Copy link
Contributor Author
pfalcon commented Jul 29, 2018

https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html

Except by explicit request, make exports a variable only if it is either defined in the environment initially or set on the command line

I.e. resetting MAKEFLAGS is not enough, because if run like make CROSS_COMPILE=foo, that will be exported automagically to the submake. So, either explicit resets on submake invocation, or HOST_CC and friends.

@dpgeorge
Copy link
Member

explicit resets on submake invocation,

I don't think this approach will work for variables that are either set if they aren't already set (eg BUILD) or if they are just set to something explicitly (eg COPT, PROG).

@pfalcon
Copy link
Contributor Author
pfalcon commented Aug 14, 2018

Well, maybe it won't work for everything, but is already used in a number of places and works well there, e.g. https://github.com/micropython/micropython/blob/master/ports/unix/Makefile#L212

The "right" way is definitely yo define HOST_* vars for CC, CFLAGS, etc., but it's very verbose and likely will be cumbersome.

And in either case, this patch provides minimal changes required to cross-build uPy with fresh checkout or during development (because any change to py/* will also trigger rebuild of mpy-cross, if CC is cross-compiler, kaboom).

@pfalcon
Copy link
Contributor Author
pfalcon commented Aug 14, 2018

(For reference, CI failure, with "coverage/coveralls — Coverage decreased (-0.006%)" is apparently a glitch.)

@dpgeorge
Copy link
Member

And in either case, this patch provides minimal changes required to cross-build uPy with fresh checkout or during development

Yes, agreed. Merged in ab78fe0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0