Skip to content

Windows: test_conststructs failure #11

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

Closed
SigmundVik opened this issue May 6, 2011 · 2 comments
Closed

Windows: test_conststructs failure #11

SigmundVik opened this issue May 6, 2011 · 2 comments

Comments

@SigmundVik
Copy link
Contributor

On my Windows 7 system, running:

runner clang_0_0.test_conststructs

gives this output:

======================================================================
ERROR: test_conststructs (__main__.clang_0_0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Y:\emscripten\tests\runner.py", line 1117, in test_conststructs
    self.do_test(src, '*70,97,15,3,3029,90*')
  File "Y:\emscripten\tests\runner.py", line 322, in do_test
    self.assertContained(expected_output, js_output)
  File "Y:\emscripten\tests\runner.py", line 276, in assertContained
    raise Exception("Expected to find '%s' in '%s'" % (limit_size(value), limit_size(string)))
Exception: Expected to find '*70,97,15,3,3029,90*' in '*70,97,9900,0.12,3029,90*
'

----------------------------------------------------------------------
Ran 1 test in 0.391s

FAILED (errors=1)

Here are the generated src.cpp.o.ll and src.cpp.o.js files:
http://pastebin.com/krJWXweS
http://pastebin.com/bkwFWGjy

The problem seems to be that the double member variable in the IUB struct is not correctly aligned/padded. Emscripten seems to think that the size of the IUB struct is 16 bytes, wheras clang will align and pad the double in a way that makes the struct 24 bytes.

The problem can be observed in the generated src.cpp.o.js file where Emscripten allocates 64 "bytes" (16 "bytes" for each entry in the iub array):

var $iub=__stackBase__+16;
var $after=__stackBase__+80;

but then goes ahead and copies 96 "bytes" when initializing the array:

_llvm_memcpy_p0i8_p0i8_i32($4, __ZZ4mainE3iub, 96, 8, 0);
@kripken
Copy link
Member

kripken commented May 10, 2011

Thanks for reporting this issue. Your analysis looks correct to me.

The structure has fields of size 4-8-4, which on Linux gets aligned basically as-is. On Windows, if it gets to size 24, I would guess it ends up as 4-(4 padding to align the 8)-8-4-(4 padding to make the total a multiple of 8). Presumably this information is encoded in the |datalayout| section in the .ll file, which Emscripten currently ignores, so we should address that.

@kripken
Copy link
Member

kripken commented Oct 13, 2011

Emscripten now uses bundled headers, so it should work on Windows exactly the same as on all other platforms.

I'm closing this issue, but if you see that the problem still exists, please reopen.

@kripken kripken closed this as completed Oct 13, 2011
tlively pushed a commit to tlively/emscripten that referenced this issue Mar 23, 2022
Make file_packager.py compatible with PThreadFS
steveisok pushed a commit to steveisok/emscripten that referenced this issue Sep 18, 2023
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

No branches or pull requests

2 participants