{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/256","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/256/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/256/events","html_url":"https://github.com/ocaml/ocaml/pull/256","id":110648002,"number":256,"title":"configure: use preprocessor to get infos about target arch","user":{"login":"the2masters","id":587423,"avatar_url":"https://avatars.githubusercontent.com/u/587423?v=3","gravatar_id":"","url":"https://api.github.com/users/the2masters","html_url":"https://github.com/the2masters","followers_url":"https://api.github.com/users/the2masters/followers","following_url":"https://api.github.com/users/the2masters/following{/other_user}","gists_url":"https://api.github.com/users/the2masters/gists{/gist_id}","starred_url":"https://api.github.com/users/the2masters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the2masters/subscriptions","organizations_url":"https://api.github.com/users/the2masters/orgs","repos_url":"https://api.github.com/users/the2masters/repos","events_url":"https://api.github.com/users/the2masters/events{/privacy}","received_events_url":"https://api.github.com/users/the2masters/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-09T12:29:43Z","updated_at":"2015-10-09T16:46:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/256","html_url":"https://github.com/ocaml/ocaml/pull/256","diff_url":"https://github.com/ocaml/ocaml/pull/256.diff","patch_url":"https://github.com/ocaml/ocaml/pull/256.patch"},"body":"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.\r\nWhen 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.\r\n\r\nSo 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.\r\n\r\nThere 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.\r\nIs this test really needed? Which compiler do misbehave? Sind C99 round to zero is mandated by the C Standard.\r\n\r\n[1] https://openwrt.org/"},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/146927229","html_url":"https://github.com/ocaml/ocaml/pull/256#issuecomment-146927229","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/256","id":146927229,"user":{"login":"xavierleroy","id":3845810,"avatar_url":"https://avatars.githubusercontent.com/u/3845810?v=3","gravatar_id":"","url":"https://api.github.com/users/xavierleroy","html_url":"https://github.com/xavierleroy","followers_url":"https://api.github.com/users/xavierleroy/followers","following_url":"https://api.github.com/users/xavierleroy/following{/other_user}","gists_url":"https://api.github.com/users/xavierleroy/gists{/gist_id}","starred_url":"https://api.github.com/users/xavierleroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavierleroy/subscriptions","organizations_url":"https://api.github.com/users/xavierleroy/orgs","repos_url":"https://api.github.com/users/xavierleroy/repos","events_url":"https://api.github.com/users/xavierleroy/events{/privacy}","received_events_url":"https://api.github.com/users/xavierleroy/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T16:46:40Z","updated_at":"2015-10-09T16:46:40Z","body":"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.\")  \r\n\r\nEndianness detection, on the other hand, is hopelessly not portable; at best, it could be a fallback best effort in the cross-compilation case.\r\n\r\nConcerning the test for negative division, it is not needed for C99 indeed, and was removed in the trunk sources.\r\n\r\nI 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?  \r\n"}}