{"action":"created","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/4538","repository_url":"https://api.github.com/repos/kripken/emscripten","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/4538/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/4538/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/4538/events","html_url":"https://github.com/kripken/emscripten/issues/4538","id":174675923,"number":4538,"title":"The result of -O2 --closure 1 -s MODULARIZE=1 is broken","user":{"login":"tomykaira","id":789929,"avatar_url":"https://avatars.githubusercontent.com/u/789929?v=3","gravatar_id":"","url":"https://api.github.com/users/tomykaira","html_url":"https://github.com/tomykaira","followers_url":"https://api.github.com/users/tomykaira/followers","following_url":"https://api.github.com/users/tomykaira/following{/other_user}","gists_url":"https://api.github.com/users/tomykaira/gists{/gist_id}","starred_url":"https://api.github.com/users/tomykaira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomykaira/subscriptions","organizations_url":"https://api.github.com/users/tomykaira/orgs","repos_url":"https://api.github.com/users/tomykaira/repos","events_url":"https://api.github.com/users/tomykaira/events{/privacy}","received_events_url":"https://api.github.com/users/tomykaira/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-02T04:00:44Z","updated_at":"2016-10-10T23:52:05Z","closed_at":null,"body":"Because `MODULARIZE` assumes that the following code uses name `Module`, when `closure` and `O2` are specified, it is no the case.\r\n\r\n```\r\nemcc -O2 --closure 1 -s MODULARIZE=1 main.c\r\n```\r\n\r\nmain.c\r\n\r\n```\r\n#include <emscripten.h>\r\n\r\nint main(int argc, char *argv[]) {\r\n  printf(\"hello\\n\");\r\n  return 0;\r\n}\r\n```\r\n\r\noutput js:\r\n\r\n```\r\nvar Module = function(Module) {\r\n  Module = Module || {};\r\n\r\nvar b;b||(b=eval(\"(function() { try { return Module || {} } catch(e) { return {} } })()\"));var g={},l;for(l in b)b.hasOwnProperty(l)&&(g[l]=b[l]);var n=!1,p=!1,r=!1,t=!1;\r\n...\r\n...\r\n\r\n  return Module;\r\n};\r\n```\r\n\r\nBecause `Module` and `b` differ, the function returns empty object. This behavior is inconsistent the output without `-O2` or `-closure 1`. The problem may be more clear with `-s EXPORT_NAME'\"exportName\"'`."},"comment":{"url":"https://api.github.com/repos/kripken/emscripten/issues/comments/252775905","html_url":"https://github.com/kripken/emscripten/issues/4538#issuecomment-252775905","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/4538","id":252775905,"user":{"login":"SaschaNaz","id":3396686,"avatar_url":"https://avatars.githubusercontent.com/u/3396686?v=3","gravatar_id":"","url":"https://api.github.com/users/SaschaNaz","html_url":"https://github.com/SaschaNaz","followers_url":"https://api.github.com/users/SaschaNaz/followers","following_url":"https://api.github.com/users/SaschaNaz/following{/other_user}","gists_url":"https://api.github.com/users/SaschaNaz/gists{/gist_id}","starred_url":"https://api.github.com/users/SaschaNaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SaschaNaz/subscriptions","organizations_url":"https://api.github.com/users/SaschaNaz/orgs","repos_url":"https://api.github.com/users/SaschaNaz/repos","events_url":"https://api.github.com/users/SaschaNaz/events{/privacy}","received_events_url":"https://api.github.com/users/SaschaNaz/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T23:52:05Z","updated_at":"2016-10-10T23:52:05Z","body":"A fix is now merged and you can try it on incoming branch :D"}}
{"actor":{"display_login":"SaschaNaz"}}