Skip to content
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

A handful of improvements related to cross compiling #562

Merged
merged 6 commits into from
May 19, 2024

Conversation

agoode
Copy link
Contributor

@agoode agoode commented May 13, 2024

This was split off of #550.

  • Two of these fix some minor compiler warnings.
  • One automates rounding mode detection (WASM only supports the 1 rounding mode, and it turns out POSIX already provides a mechanism to detect this).
  • The last three commits make it easier to build and install multiple cross-compiler targets at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since CC and GMP_*_DIR variables are set via $(LIB)/targets/$(TARGET)/vars rather than directly in the mlton script, then a corresponding changes should be made to the Makefile.binary (https://github.com/MLton/mlton/blob/master/Makefile.binary#L69-L73), which allows for customizing those values when updating/installing a binary release. That can assume that TARGET is self.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've updated Makefile.binary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is quite right. The Makefile.binary is copied into a binary release as Makefile to facilitate updating and installing a binary release. In particular, one uses the update target to adjust things like CC and GMP_LIB if they are different on the client machine than on the build machine. For example, one might do something like make CC=/path/to/clang update if the default cc isn't a suitable C compiler on the client machine.

So, I think the diff to Makefile.binary is more like:

 
 .PHONY: update
 update:
-	$(CP) "$(SBIN)/mlton" "$(SBIN)/mlton.bak"
+	$(CP) "$(SLIB)/targets/self/vars" "$(SLIB)/targets/self/vars.bak"
 	$(SED) \
 		-e "s;^CC=.*;CC=\"$(CC)\";" \
 		-e "s;^GMP_INC_DIR=.*;GMP_INC_DIR=$(if $(WITH_GMP_INC_DIR),\"$(WITH_GMP_INC_DIR)\");" \
 		-e "s;^GMP_LIB_DIR=.*;GMP_LIB_DIR=$(if $(WITH_GMP_LIB_DIR),\"$(WITH_GMP_LIB_DIR)\");" \
-		< "$(SBIN)/mlton.bak" > "$(SBIN)/mlton"
-	chmod a+x "$(SBIN)/mlton"
-	$(RM) "$(SBIN)/mlton.bak"
+		< "$(SLIB)/targets/self/vars.bak" > "$(SLIB)/targets/self/vars"
+	$(RM) "$(SLIB)/targets/self/vars.bak"
 	$(CP) "$(SLIB)/targets/self/constants" "$(SLIB)/targets/self/constants.bak"
 	$(SED) \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Thank you. I had it 100% backwards. It should be good now.

As defined in the standard, each of these macros are
only defined if the platform supports that rounding mode.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fenv.h.html
This will allow running mlton as a cross-compiler more easily, since the CC and GMP vars may be different between targets.
This makes it easier to build multiple per-target runtime targets and install them together.
This makes any `-target` flag get passed to get the right OBJPTR_REP for cross regressions.
@MatthewFluet MatthewFluet merged commit 475cf2b into MLton:master May 19, 2024
12 checks passed
@agoode agoode deleted the misc branch May 19, 2024 18:31
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