adobe-flash/crossbridge

Automatically generated exports passed to -flto-api not working

DarioAhdoot opened this issue · 1 comments

We're having problems with our automatically generated exports.txt file. We are producing the file dynamically exactly as outlined here:

http://www.adobe.com/devnet/games/articles/using-cplusplus-code-path-finding.html

The problem is that the nm command (and grep/sed/awk commands) emits C symbols with a preceding underscore. e.g. a global variable named "foo" shows up in the exports file as "_foo". When we try and access foo from action script like so:

var foo:int = CModule.read32(CModule.getPublicSymbol("foo"))

we get an exception of this sort:

ReferenceError: Error #1065: Variable _foo is not defined.
    at com.adobe.flascc::CModule$/getPublicSymbol()
    at com.adobe.flascc::Console/enterFrame()

If we manually remove the underscore from _foo in the exports.txt file, the issue goes away.

In Alex Mac's OpenCV example, he includes a statically generated exports.txt file which references a global variable called "imageData". The exports.txt file contains "imageData" not "_imageData". If we run the nm/grep/sed/awk command on his OpenCV faceTracker.cpp file, the exports.txt generated has "_imageData" and his face tracker demo fails to work.

Any idea what we should be doing here?

If I don't remember wrong...
The way in future branch is different with master branch.
In future branch, symbols are processed normally like native way. Means that normal external symbols prefix '' except builtin atomic ops.
In master branch, symbols are remaining untouched. So have to manually prefix '
' to accommodate external symbols lookup.

So it's mixing since in AS there is no external symbol prefixing or name mangling, but when you access symbols which come from C/C++, should make a symbol wrapping.
Hope this is correct and clear.