Skip to content
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

Hello world milestion for clang toolchain #14

Open
stopiccot opened this issue Jul 22, 2013 · 22 comments
Open

Hello world milestion for clang toolchain #14

stopiccot opened this issue Jul 22, 2013 · 22 comments

Comments

@stopiccot
Copy link
Contributor

Simple hello world application

#include <stdio.h>

int main() {
    printf("flascc test\n");
    return 0;
}

Compilation

 stopiccot$ .../crossbridge/sdk/usr/bin/clang++ main.cpp -emit-swf -o ~/output.swf
 compiling for C++
 .../crossbridge/sdk/usr/bin/ld: error: cannot open /stdlibs_abc/libstdc++.a: No such file or directory
 .../crossbridge/sdk/usr/bin/ld: error: cannot open /stdlibs_abc/libsupc++.a: No such file or directory
 .../crossbridge/sdk/usr/bin/ld: error: cannot open /stdlibs_abc/libcHack.o: No such file or directory
 .../crossbridge/sdk/usr/bin/ld: error: cannot open /stdlibs_abc/libm.o: No such file or directory
 .../crossbridge/sdk/usr/bin/ld: error: cannot open /stdlibs_abc/libc.a: No such file or directory
 .../crossbridge/sdk/usr/bin/ld: error: cannot find -lstdc++
 .../crossbridge/sdk/usr/bin/../../usr/lib/CModule.abc: error: undefined reference to '_malloc'
 .../crossbridge/sdk/usr/bin/../../usr/lib/CModule.abc: error: undefined reference to '_free'
 .../crossbridge/sdk/usr/bin/../../usr/lib/CModule.abc: error: undefined reference to '_flascc_uiTickProc'
 /var/folders/gy/5rs8cgt96sj_1bf1qxcpqmtw0000gn/T/main-qco5Ry.o: error: undefined reference to '_printf'
 .../crossbridge/sdk/usr/bin/../../usr/lib//stdlibs_abc/crt1_c.o: error: undefined reference to '_atexit'
 .../crossbridge/sdk/usr/bin/../../usr/lib//stdlibs_abc/crt1_c.o: error: undefined reference to '__init_tls'
 .../crossbridge/sdk/usr/bin/../../usr/lib//stdlibs_abc/crt1_c.o: error: undefined reference to '__fini'
 .../crossbridge/sdk/usr/bin/../../usr/lib//stdlibs_abc/crt1_c.o: error: undefined reference to '__init'
 .../crossbridge/sdk/usr/bin/../../usr/lib//stdlibs_abc/crt1_c.o: error: undefined reference to '_exit'
 Warning: Multiply defined: Qname: PlayerKernel::{PackageNs:"com.adobe.flascc.kernel"}
 Warning: Multiply defined: Qname: createRawWorker::{PackageNs:"C_Run"}
 Warning: Multiply defined: Qname: createflasccWorker::{PackageNs:"C_Run"}
 clang++: error: linker command failed with exit code 1 (use -v to see invocation)
@cbakgly
Copy link
Contributor

cbakgly commented Jul 24, 2013

Yes, libc++ is not ready now. There's still plenty of work including libc upgrading.

@cbakgly
Copy link
Contributor

cbakgly commented Aug 20, 2013

Libc upgrading is roughly done. Wish libc++ to be done soon.

@stopiccot
Copy link
Contributor Author

Any progress with libc++?

@cbakgly
Copy link
Contributor

cbakgly commented Sep 12, 2013

I think it will be done very soon. I can upload the files if you'd like to try it.

Oh, I am a little over-optimistic. So let code in first.

@stopiccot
Copy link
Contributor Author

Hi. Just tested commit e6b4dfe. I'm getting a few errors. First one occurs while building stdlibs target:

/Users/stopiccot/code/flash/crossbridge/build/mac/libthr/libthr/thread/thr_exit.c:110:1: error: conflicting types for '_Unwind_GetCFA'
_Unwind_GetCFA(struct _Unwind_Context *context)

which can be fixed obviously. The second occurs while building as3wig target and seems to be more complex:

In file included from AS3Wig.cpp:22:
In file included from /Users/stopiccot/code/flash/crossbridge/sdk/usr/bin/../../usr/include/AS3++/AS3Wig.h:23:
In file included from /Users/stopiccot/code/flash/crossbridge/sdk/usr/bin/../../usr/include/AS3/AS3++.h:16:
In file included from /Users/stopiccot/code/flash/crossbridge/sdk/usr/bin/../../usr/include/c++/4.2/string:56:
In file included from /Users/stopiccot/code/flash/crossbridge/sdk/usr/bin/../../usr/include/c++/4.2/algorithm:67:
/Users/stopiccot/code/flash/crossbridge/sdk/usr/bin/../../usr/include/c++/4.2/bits/stl_algo.h:1985:40: error: no member named 'rand' in namespace 'std'
      std::iter_swap(__i, __first + (std::rand() % ((__i - __first) + 1)));
                                     ~~~~~^

It seems that despite we should use libc++, gcc 4.2 headers are somehow getting into compilation which is obviously incorrect. Looking forward for your response.

@stopiccot
Copy link
Contributor Author

Hi. Just tested commit 37b738b. I've changed my main.cpp to:

#include <iostream>

int main() {
    std::cout << "crossbridge test" << std::endl;
    return 0;
}

It compiled fine using command line:

$ .../crossbridge/sdk/usr/bin/clang++ ./main.cpp -emit-swf -o ~/test.swf

It's already a good milestone :) But generated swf crashes on startup. Here is what I have in my flashlog.txt:

Error
    at global/C_Run::F__sync_val_compare_and_swap_1()
    at global/C_Run::F__ZNSt3__16locale8__globalEv()
    at global/C_Run::F__ZNSt3__110__stdinbufIcEC2EP7__sFILEP11__mbstate_t()
    at global/C_Run::F__ZNSt3__18ios_base4InitC2Ev()
    at global/C_Run__2F_var_2F_folders_2F_gy_2F_5rs8cgt96sj_1bf1qxcpqmtw0000gn_2F_T_2F__2F_sK9QJI_2E_lto_2E_bc_3A_6F0C363B_2D_EC8B_2D_439B_2D_86C8_2D_8F    DFED6DCB03::F__GLOBAL__I_a()
    at com.adobe.flascc::CModule$/callI()
    at com.adobe.flascc::CModule/runCtors()
    at com.adobe.flascc::CModule$/runCtors()
    at global/C_Run::F__init()
    at global/C_Run::F__start1()
    at com.adobe.flascc::CModule$/callI()
    at com.adobe.flascc::CModule$/start()
    at com.adobe.flascc::CModule$/startAsync()
    at com.adobe.flascc::Console/init()
    at com.adobe.flascc::Console()
    at com.adobe.flascc.preloader::DefaultPreloader/onPreloaderComplete()

FlasCC does not support CAS on a non-32bit values..

@cbakgly
Copy link
Contributor

cbakgly commented Sep 27, 2013

Thanks. Known issue.

@cbakgly
Copy link
Contributor

cbakgly commented Oct 8, 2013

A minor fix is uploaded. Hope it works all the time.

@rtissera
Copy link

What toolchain/OS combo do you use guys to get the futures branch "working" ?

@cbakgly
Copy link
Contributor

cbakgly commented Oct 14, 2013

@rtissera Mac OS X Lion 10.7.5 (11G63b) + Xcode Version 4.6.3 (4H1503).
Also major parts are also working in Cygwin.

@stopiccot
Copy link
Contributor Author

Hi. Recent commits to futures branch made it workable for simple test programs that use C++11 features. So I decided to test our project. I'm getting a lot of weird link time errors:

error: z: no archive symbol table (run ranlib)
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 7992 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 286344 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 289732 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 340280 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 371328 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 389676 is not an ELF object
....

Do you have any idea what can be causing these errors?

@rtissera
Copy link

It's better for me :)
I just missed the following symbols at link time :

_powl
__openat
__fstatat

Seems missing from libc.a :(

2013/10/17 Alexey notifications@github.com

Hi. Recent commits to futures branch made it workable for simple test
programs that use C++11 features. So I decided to test our project. I'm
getting a lot of weird link time errors:

error: z: no archive symbol table (run ranlib)
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 7992 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 286344 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 289732 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 340280 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 371328 is not an ELF object
error: LLVM gold plugin has failed to create LTO module: Invalid MODULE_CODE_GLOBALVAR record
error: SDL: member at 389676 is not an ELF object
....

Do you have any idea what can be causing these errors?


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-26532495
.

@cbakgly
Copy link
Contributor

cbakgly commented Oct 18, 2013

@stopiccot Did you use the file made by previous version of LLVM?
You may take a look at line 384 at llvm-3.2/tools/gold/gold-plugin.cpp.

@cbakgly
Copy link
Contributor

cbakgly commented Oct 18, 2013

@rtissera
powl, make it an alias of pow.
openat is in thread lib.
fstatat, you should not rely on such APIs, otherwise have to implement yourself. Image that how can you access the real file system in Flash Player?

@rtissera
Copy link

Not using openat neither fstatat directly in my code, it seems to be called by some underneath library or API hidden by Crossbridge. Using ZipBackingStore VFS btw, maybe the source of the issue ?

@stopiccot
Copy link
Contributor Author

@cbakgly Yes, you are right. There were some mess with libs compiled by master branch version of crossbridge. I've tried to recompile dependencies (https://github.com/alexmac/alcextra) using newer crossbridge:

libtool: link: ranlib build/.libs/libSDL_mixer.a
bfd plugin: Failed to create LLVM module: Unknown bitstream version!
ld: warning: ignoring file build/.libs/libSDL_mixer.a, file was built for archive which is not the architecture being linked (x86_64): build/.libs/libSDL_mixer.a
ld: file too small for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@stopiccot
Copy link
Contributor Author

I've also compiled our project once again (but with libSDL_mixer disabled). This time it compiled and linked successfully. But when I try to run it using Flash Player Debugger 11.2.202.228 it fails on printf() call:

ReferenceError: Error #1065: Variable F_puts is not defined.

I have no idea why it is happening because simple test programs (int main() with just one printf()) wok fine for me. Any ideas what can be causing this issue?

@cbakgly
Copy link
Contributor

cbakgly commented Oct 21, 2013

@stopiccot
I feel that they both are version-mixed issues.
1st, like a different LLVM bitcode version. Just note that LLVM bitcode is not completely compatible. So a file from 2.9 should not be used to link with 3.2.
2nd, I think you used a bitcode file gen'ed from 2.9 compiler, and use it with 3.2 compiler. Because with previous one, 'put' will be converted later into some function; but in 3.2 "printf" just keeps its name. For this part I don't remember clearly. Hope I am right.

@cbakgly
Copy link
Contributor

cbakgly commented Oct 21, 2013

@rtissera Hmm, maybe you are right. Does Crossbridge has a ZipBackingStore?

@rtissera
Copy link

ZipBackingStore is a custom alcextra class based on InMemoryBackingStore

2013/10/21 Ye Liu notifications@github.com

@rtissera https://github.com/rtissera Hmm, maybe you are right. Does
Crossbridge has a ZipBackingStore?


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-26699093
.

@cbakgly
Copy link
Contributor

cbakgly commented Oct 22, 2013

Oh yes, but guess he won't update anymore :(

@alexmac
Copy link

alexmac commented Oct 22, 2013

If anyone wants commit access to the various alc* repos on my github page just send me a pull request, having a futures branch for each of them would be great but I probably won't have time to keep them up to date myself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants