{"action":"created","comment":{"url":"https://api.github.com/repos/mesonbuild/meson/pulls/comments/183918486","pull_request_review_id":115010021,"id":183918486,"diff_hunk":"@@ -998,44 +998,75 @@ def run(self, code, env, extra_args=None, dependencies=None):\n         mlog.debug(se)\n         return RunResult(True, pe.returncode, so, se)\n \n-    def _bisect_compiles(self, t, fargs, env, extra_args, dependencies):\n-        # FIXME: Does not actually do bisection right now\n-        for i in range(1, 1024):\n-            fargs['size'] = i\n-            if self.compiles(t.format(**fargs), env, extra_args, dependencies):\n-                if self.id == 'msvc':\n-                    # MSVC refuses to construct an array of zero size, so\n-                    # the test only succeeds when i is sizeof(element) + 1\n-                    return i - 1\n-                return i\n+    def _compile_int(self, expression, prefix, env, extra_args, dependencies):\n+        fargs = {'prefix': prefix, 'expression': expression}\n+        t = '''#include <stdio.h>\n+        {prefix}\n+        int main() {{ static int a[1-2*!({expression})]; a[0]=0; return 0; }}'''\n+        return self.compiles(t.format(**fargs), env, extra_args, dependencies)\n+\n+    def cross_compute_int(self, expression, l, h, guess, prefix, env, extra_args, dependencies):\n+        if isinstance(guess, int):\n+            if self._compile_int('%s == %d' % (expression, guess), prefix, env, extra_args, dependencies):\n+                return guess\n+\n+        cur = l\n+        while l < h:\n+            cur = int((l + h) / 2)\n+            if cur == l:\n+                break\n+\n+            if self._compile_int('%s >= %d' % (expression, cur), prefix, env, extra_args, dependencies):\n+                l = cur\n+            else:\n+                h = cur\n+\n+        if self._compile_int('%s == %d' % (expression, cur), prefix, env, extra_args, dependencies):\n+            return cur\n         raise EnvironmentException('Cross-compile check overflowed')\n \n-    def cross_sizeof(self, element, prefix, env, extra_args=None, dependencies=None):\n+    def compute_int(self, expression, l, h, guess, prefix, env, extra_args=None, dependencies=None):\n+        if extra_args is None:\n+            extra_args = []\n+        if self.is_cross:\n+            return self.cross_compute_int(expression, l, h, guess, prefix, env, extra_args, dependencies)\n+        fargs = {'prefix': prefix, 'expression': expression}\n+        t = '''#include<stdio.h>\n+        {prefix}\n+        int main(int argc, char **argv) {{\n+            printf(\"%ld\\\\n\", (long)({expression}));\n+            return 0;\n+        }};'''\n+        res = self.run(t.format(**fargs), env, extra_args, dependencies)\n+        if not res.compiled:\n+            return -1\n+        if res.returncode != 0:\n+            raise EnvironmentException('Could not run compute_int test binary.')\n+        return int(res.stdout)\n+\n+    def cross_sizeof(self, typename, prefix, env, extra_args=None, dependencies=None):\n         if extra_args is None:\n             extra_args = []\n-        fargs = {'prefix': prefix, 'name': element}\n+        fargs = {'prefix': prefix, 'type': typename}\n         t = '''#include <stdio.h>\n         {prefix}\n         int main(int argc, char **argv) {{\n-            {name} something;\n+            {type} something;\n         }}'''\n         if not self.compiles(t.format(**fargs), env, extra_args, dependencies):\n             return -1\n-        t = '''#include <stdio.h>\n-        {prefix}\n-        int temparray[{size}-sizeof({name})];'''\n-        return self._bisect_compiles(t, fargs, env, extra_args, dependencies)\n+        return self.cross_compute_int('sizeof(%s)' % typename, 1, 128, None, prefix, env, extra_args, dependencies)","path":"mesonbuild/compilers.py","position":78,"original_position":78,"commit_id":"2f11e2e4630a7770eddbce7efdd7ce9b63de5ba1","original_commit_id":"2f11e2e4630a7770eddbce7efdd7ce9b63de5ba1","user":{"login":"jharvell","id":7919228,"avatar_url":"https://avatars1.githubusercontent.com/u/7919228?v=4","gravatar_id":"","url":"https://api.github.com/users/jharvell","html_url":"https://github.com/jharvell","followers_url":"https://api.github.com/users/jharvell/followers","following_url":"https://api.github.com/users/jharvell/following{/other_user}","gists_url":"https://api.github.com/users/jharvell/gists{/gist_id}","starred_url":"https://api.github.com/users/jharvell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jharvell/subscriptions","organizations_url":"https://api.github.com/users/jharvell/orgs","repos_url":"https://api.github.com/users/jharvell/repos","events_url":"https://api.github.com/users/jharvell/events{/privacy}","received_events_url":"https://api.github.com/users/jharvell/received_events","type":"User","site_admin":false},"body":"With this change, you have reduced the max size that can be detected on a cross compiled system from 1024 to 128.  This breaks the cross compile of systemd (at least on Gentoo).  See https://bugs.gentoo.org/654026","created_at":"2018-04-25T00:40:53Z","updated_at":"2018-04-25T00:40:54Z","html_url":"https://github.com/mesonbuild/meson/pull/1456#discussion_r183918486","pull_request_url":"https://api.github.com/repos/mesonbuild/meson/pulls/1456","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/mesonbuild/meson/pulls/comments/183918486"},"html":{"href":"https://github.com/mesonbuild/meson/pull/1456#discussion_r183918486"},"pull_request":{"href":"https://api.github.com/repos/mesonbuild/meson/pulls/1456"}}},"pull_request":{"url":"https://api.github.com/repos/mesonbuild/meson/pulls/1456","id":109914582,"html_url":"https://github.com/mesonbuild/meson/pull/1456","diff_url":"https://github.com/mesonbuild/meson/pull/1456.diff","patch_url":"https://github.com/mesonbuild/meson/pull/1456.patch","issue_url":"https://api.github.com/repos/mesonbuild/meson/issues/1456","number":1456,"state":"closed","locked":false,"title":"Add compute_int, fixes #435","user":{"login":"haaspors","id":352842,"avatar_url":"https://avatars3.githubusercontent.com/u/352842?v=4","gravatar_id":"","url":"https://api.github.com/users/haaspors","html_url":"https://github.com/haaspors","followers_url":"https://api.github.com/users/haaspors/followers","following_url":"https://api.github.com/users/haaspors/following{/other_user}","gists_url":"https://api.github.com/users/haaspors/gists{/gist_id}","starred_url":"https://api.github.com/users/haaspors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haaspors/subscriptions","organizations_url":"https://api.github.com/users/haaspors/orgs","repos_url":"https://api.github.com/users/haaspors/repos","events_url":"https://api.github.com/users/haaspors/events{/privacy}","received_events_url":"https://api.github.com/users/haaspors/received_events","type":"User","site_admin":false},"body":null,"created_at":"2017-03-09T13:37:12Z","updated_at":"2018-04-25T00:40:54Z","closed_at":"2017-03-23T20:02:40Z","merged_at":"2017-03-23T20:02:40Z","merge_commit_sha":"df1480fe11e5d4f20b7305abc2129d3c6494d1b5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mesonbuild/meson/pulls/1456/commits","review_comments_url":"https://api.github.com/repos/mesonbuild/meson/pulls/1456/comments","review_comment_url":"https://api.github.com/repos/mesonbuild/meson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesonbuild/meson/issues/1456/comments","statuses_url":"https://api.github.com/repos/mesonbuild/meson/statuses/2f11e2e4630a7770eddbce7efdd7ce9b63de5ba1","head":{"label":"haaspors:compute_int","ref":"compute_int","sha":"2f11e2e4630a7770eddbce7efdd7ce9b63de5ba1","user":{"login":"haaspors","id":352842,"avatar_url":"https://avatars3.githubusercontent.com/u/352842?v=4","gravatar_id":"","url":"https://api.github.com/users/haaspors","html_url":"https://github.com/haaspors","followers_url":"https://api.github.com/users/haaspors/followers","following_url":"https://api.github.com/users/haaspors/following{/other_user}","gists_url":"https://api.github.com/users/haaspors/gists{/gist_id}","starred_url":"https://api.github.com/users/haaspors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haaspors/subscriptions","organizations_url":"https://api.github.com/users/haaspors/orgs","repos_url":"https://api.github.com/users/haaspors/repos","events_url":"https://api.github.com/users/haaspors/events{/privacy}","received_events_url":"https://api.github.com/users/haaspors/received_events","type":"User","site_admin":false},"repo":{"id":44176387,"name":"meson","full_name":"haaspors/meson","owner":{"login":"haaspors","id":352842,"avatar_url":"https://avatars3.githubusercontent.com/u/352842?v=4","gravatar_id":"","url":"https://api.github.com/users/haaspors","html_url":"https://github.com/haaspors","followers_url":"https://api.github.com/users/haaspors/followers","following_url":"https://api.github.com/users/haaspors/following{/other_user}","gists_url":"https://api.github.com/users/haaspors/gists{/gist_id}","starred_url":"https://api.github.com/users/haaspors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haaspors/subscriptions","organizations_url":"https://api.github.com/users/haaspors/orgs","repos_url":"https://api.github.com/users/haaspors/repos","events_url":"https://api.github.com/users/haaspors/events{/privacy}","received_events_url":"https://api.github.com/users/haaspors/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/haaspors/meson","description":"The Meson Build System","fork":true,"url":"https://api.github.com/repos/haaspors/meson","forks_url":"https://api.github.com/repos/haaspors/meson/forks","keys_url":"https://api.github.com/repos/haaspors/meson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haaspors/meson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haaspors/meson/teams","hooks_url":"https://api.github.com/repos/haaspors/meson/hooks","issue_events_url":"https://api.github.com/repos/haaspors/meson/issues/events{/number}","events_url":"https://api.github.com/repos/haaspors/meson/events","assignees_url":"https://api.github.com/repos/haaspors/meson/assignees{/user}","branches_url":"https://api.github.com/repos/haaspors/meson/branches{/branch}","tags_url":"https://api.github.com/repos/haaspors/meson/tags","blobs_url":"https://api.github.com/repos/haaspors/meson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haaspors/meson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haaspors/meson/git/refs{/sha}","trees_url":"https://api.github.com/repos/haaspors/meson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haaspors/meson/statuses/{sha}","languages_url":"https://api.github.com/repos/haaspors/meson/languages","stargazers_url":"https://api.github.com/repos/haaspors/meson/stargazers","contributors_url":"https://api.github.com/repos/haaspors/meson/contributors","subscribers_url":"https://api.github.com/repos/haaspors/meson/subscribers","subscription_url":"https://api.github.com/repos/haaspors/meson/subscription","commits_url":"https://api.github.com/repos/haaspors/meson/commits{/sha}","git_commits_url":"https://api.github.com/repos/haaspors/meson/git/commits{/sha}","comments_url":"https://api.github.com/repos/haaspors/meson/comments{/number}","issue_comment_url":"https://api.github.com/repos/haaspors/meson/issues/comments{/number}","contents_url":"https://api.github.com/repos/haaspors/meson/contents/{+path}","compare_url":"https://api.github.com/repos/haaspors/meson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haaspors/meson/merges","archive_url":"https://api.github.com/repos/haaspors/meson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haaspors/meson/downloads","issues_url":"https://api.github.com/repos/haaspors/meson/issues{/number}","pulls_url":"https://api.github.com/repos/haaspors/meson/pulls{/number}","milestones_url":"https://api.github.com/repos/haaspors/meson/milestones{/number}","notifications_url":"https://api.github.com/repos/haaspors/meson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haaspors/meson/labels{/name}","releases_url":"https://api.github.com/repos/haaspors/meson/releases{/id}","deployments_url":"https://api.github.com/repos/haaspors/meson/deployments","created_at":"2015-10-13T12:58:53Z","updated_at":"2015-10-13T12:58:55Z","pushed_at":"2017-03-10T11:33:34Z","git_url":"git://github.com/haaspors/meson.git","ssh_url":"git@github.com:haaspors/meson.git","clone_url":"https://github.com/haaspors/meson.git","svn_url":"https://github.com/haaspors/meson","homepage":null,"size":6188,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mesonbuild:master","ref":"master","sha":"1713aef364560c9de922991716880e4db32f88a5","user":{"login":"mesonbuild","id":12551236,"avatar_url":"https://avatars0.githubusercontent.com/u/12551236?v=4","gravatar_id":"","url":"https://api.github.com/users/mesonbuild","html_url":"https://github.com/mesonbuild","followers_url":"https://api.github.com/users/mesonbuild/followers","following_url":"https://api.github.com/users/mesonbuild/following{/other_user}","gists_url":"https://api.github.com/users/mesonbuild/gists{/gist_id}","starred_url":"https://api.github.com/users/mesonbuild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesonbuild/subscriptions","organizations_url":"https://api.github.com/users/mesonbuild/orgs","repos_url":"https://api.github.com/users/mesonbuild/repos","events_url":"https://api.github.com/users/mesonbuild/events{/privacy}","received_events_url":"https://api.github.com/users/mesonbuild/received_events","type":"Organization","site_admin":false},"repo":{"id":19784232,"name":"meson","full_name":"mesonbuild/meson","owner":{"login":"mesonbuild","id":12551236,"avatar_url":"https://avatars0.githubusercontent.com/u/12551236?v=4","gravatar_id":"","url":"https://api.github.com/users/mesonbuild","html_url":"https://github.com/mesonbuild","followers_url":"https://api.github.com/users/mesonbuild/followers","following_url":"https://api.github.com/users/mesonbuild/following{/other_user}","gists_url":"https://api.github.com/users/mesonbuild/gists{/gist_id}","starred_url":"https://api.github.com/users/mesonbuild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesonbuild/subscriptions","organizations_url":"https://api.github.com/users/mesonbuild/orgs","repos_url":"https://api.github.com/users/mesonbuild/repos","events_url":"https://api.github.com/users/mesonbuild/events{/privacy}","received_events_url":"https://api.github.com/users/mesonbuild/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesonbuild/meson","description":"The Meson Build System","fork":false,"url":"https://api.github.com/repos/mesonbuild/meson","forks_url":"https://api.github.com/repos/mesonbuild/meson/forks","keys_url":"https://api.github.com/repos/mesonbuild/meson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesonbuild/meson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesonbuild/meson/teams","hooks_url":"https://api.github.com/repos/mesonbuild/meson/hooks","issue_events_url":"https://api.github.com/repos/mesonbuild/meson/issues/events{/number}","events_url":"https://api.github.com/repos/mesonbuild/meson/events","assignees_url":"https://api.github.com/repos/mesonbuild/meson/assignees{/user}","branches_url":"https://api.github.com/repos/mesonbuild/meson/branches{/branch}","tags_url":"https://api.github.com/repos/mesonbuild/meson/tags","blobs_url":"https://api.github.com/repos/mesonbuild/meson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesonbuild/meson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesonbuild/meson/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesonbuild/meson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesonbuild/meson/statuses/{sha}","languages_url":"https://api.github.com/repos/mesonbuild/meson/languages","stargazers_url":"https://api.github.com/repos/mesonbuild/meson/stargazers","contributors_url":"https://api.github.com/repos/mesonbuild/meson/contributors","subscribers_url":"https://api.github.com/repos/mesonbuild/meson/subscribers","subscription_url":"https://api.github.com/repos/mesonbuild/meson/subscription","commits_url":"https://api.github.com/repos/mesonbuild/meson/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesonbuild/meson/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesonbuild/meson/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesonbuild/meson/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesonbuild/meson/contents/{+path}","compare_url":"https://api.github.com/repos/mesonbuild/meson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesonbuild/meson/merges","archive_url":"https://api.github.com/repos/mesonbuild/meson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesonbuild/meson/downloads","issues_url":"https://api.github.com/repos/mesonbuild/meson/issues{/number}","pulls_url":"https://api.github.com/repos/mesonbuild/meson/pulls{/number}","milestones_url":"https://api.github.com/repos/mesonbuild/meson/milestones{/number}","notifications_url":"https://api.github.com/repos/mesonbuild/meson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesonbuild/meson/labels{/name}","releases_url":"https://api.github.com/repos/mesonbuild/meson/releases{/id}","deployments_url":"https://api.github.com/repos/mesonbuild/meson/deployments","created_at":"2014-05-14T15:08:16Z","updated_at":"2018-04-24T02:51:48Z","pushed_at":"2018-04-25T00:29:59Z","git_url":"git://github.com/mesonbuild/meson.git","ssh_url":"git@github.com:mesonbuild/meson.git","clone_url":"https://github.com/mesonbuild/meson.git","svn_url":"https://github.com/mesonbuild/meson","homepage":"http://mesonbuild.com","size":14502,"stargazers_count":1419,"watchers_count":1419,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":366,"mirror_url":null,"archived":false,"open_issues_count":675,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":366,"open_issues":675,"watchers":1419,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesonbuild/meson/pulls/1456"},"html":{"href":"https://github.com/mesonbuild/meson/pull/1456"},"issue":{"href":"https://api.github.com/repos/mesonbuild/meson/issues/1456"},"comments":{"href":"https://api.github.com/repos/mesonbuild/meson/issues/1456/comments"},"review_comments":{"href":"https://api.github.com/repos/mesonbuild/meson/pulls/1456/comments"},"review_comment":{"href":"https://api.github.com/repos/mesonbuild/meson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesonbuild/meson/pulls/1456/commits"},"statuses":{"href":"https://api.github.com/repos/mesonbuild/meson/statuses/2f11e2e4630a7770eddbce7efdd7ce9b63de5ba1"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jharvell"}}