Skip to content

configure: use preprocessor to get infos about target arch#256

Closed
the2masters wants to merge 2 commits intoocaml:trunkfrom
the2masters:configure
Closed

configure: use preprocessor to get infos about target arch#256
the2masters wants to merge 2 commits intoocaml:trunkfrom
the2masters:configure

Conversation

@the2masters
Copy link

I'm trying to port OCaml to the openwrt router distribution [1]. Openwrt makes heavy use of cross-compiling, and supports about 40 different target archs.
When cross-compiling OCaml the configure script fails on 2 tests, it cannot detect integer and pointer sizes and it cannot detect endianess. I could now add rules and manually set the values for all 40 openwrt targets into the configure script, but I think this doesn't scale well and is only useful for openwrt.

So I sat down and wrote an alternative way to detect pointer sizes and endianess by using the preprocessor and parsing it's output. This is currently lightly tested on a few archs, so please comment and test.

There is also a test in configure script which checks if negative division rounds to zero. This check currently fails in case of cross-compile, but is only a warning. I see no way to do this check in the preprocessor.
Is this test really needed? Which compiler do misbehave? Sind C99 round to zero is mandated by the C Standard.

[1] https://openwrt.org/

@xavierleroy
Copy link
Contributor

The detection of sizes via limits.h is clever and has some chance of being portable, assuming the C standard headers conform to C99 (section 5.2.4.1, "The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives.")

Endianness detection, on the other hand, is hopelessly not portable; at best, it could be a fallback best effort in the cross-compilation case.

Concerning the test for negative division, it is not needed for C99 indeed, and was removed in the trunk sources.

I take it that for your project you're only interested in the OCaml bytecode compiler and run-time system, not the native-code compiler, right?

@the2masters
Copy link
Author

2015-10-09 18:46 GMT+02:00 Xavier Leroy [email protected]:

The detection of sizes via limits.h is clever and has some chance of being
portable, assuming the C standard headers conform to C99 (section 5.2.4.1,
"The values given below shall be replaced by constant expressions suitable
for use in #if preprocessing directives.")

Endianness detection, on the other hand, is hopelessly not portable; at
best, it could be a fallback best effort in the cross-compilation case.

I wouldn't say hopeless. I think it's more hopeless to hardcode the
endianess for every possible cross-compilation target in configure script.
Do you have any better idea? I will create a patch which will use the
preprocessor detection only in case of cross-compilation.

Concerning the test for negative division, it is not needed for C99
indeed, and was removed in the trunk sources.

I take it that for your project you're only interested in the OCaml
bytecode compiler and run-time system, not the native-code compiler, right?

I would use the native code compiler, but it's not supported for many
targets, e.g. for mips. So yes, the native compiler has a low priority. I'm
interested in getting OCaml applications as small as possible, as most
openwrt target are space constraint. Openwrt users will probably use 1 or 2
OCaml applications on a target, so I think the best way will be to compile
OCaml applications with -custom.


Reply to this email directly or view it on GitHub
#256 (comment).

@bobot
Copy link
Contributor

bobot commented Oct 12, 2015

@the2masters Why do you closed your pull request? Do you know that you can push new commits to your branch in order to update the pull-request?

@the2masters
Copy link
Author

I know, but I wanted to create a new clean pull request.

2015-10-12 8:10 GMT+02:00 François Bobot [email protected]:

@the2masters https://github.com/the2masters Why do you closed your pull
request? Do you know that you can push new commits to your branch in order
to update the pull-request?


Reply to this email directly or view it on GitHub
#256 (comment).

@the2masters the2masters deleted the configure branch October 12, 2015 11:37
@dbuenzli
Copy link
Contributor

I know, but I wanted to create a new clean pull request.

You can (and should) always force push to make the request clean based on the feedback you get. Opening new requests is annoying as it dilutes the discussions and comments across many PR, making follow up harder than it should be for everybody.

mshinwell added a commit to mshinwell/ocaml that referenced this pull request Sep 2, 2020
lthls pushed a commit to lthls/ocaml that referenced this pull request Sep 23, 2020
lthls pushed a commit to lthls/ocaml that referenced this pull request Sep 23, 2020
lthls pushed a commit to lthls/ocaml that referenced this pull request Sep 24, 2020
chambart pushed a commit to chambart/ocaml-1 that referenced this pull request Oct 5, 2021
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
* packages: Fix crash when package is removed

The query for detecting new files has been changed to using git log,
which has the disadventage of returning paths to file that have been
added then removed.
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.

4 participants