Comments (6)
Appreciate you doing that research on how one might build the LLVM IR to mark globals with the equivalent of attribute((used)) in C. I suspect you do have much of it worked out.
That said, I think there is a simpler option available near-term. Cone does distinguish between public and private globals (the latter when a name begins with an underscore), and it already marks them differently to LLVM: public globals are marked with default visibility and private ones are not. So, if you use wasm-ld's --export-dynamic, that will only take the public globals and not the private ones.
Let me know if that works for you, as I cannot test it today.
from cone.
No, --export-dynamic
also exports the fn _bro()
as well as the fn blah()
The only option to limit it to certain functions seems to be to specifically pass it via --export=blah
, then it exports only exactly that one. You are right though, that should work. I kinda read over the part that the llvm.used
stuff is only supposed to be needed for executable wasm files, which I dont need anyway.
from cone.
ok @jondgoodwin, it does work but only with the following modification because it never jumps into the first if block and even if it does, the x86 calling convention thing ruins it for wasm so I would suggest this:
if (glofn->flags & FlagSystem)
{
LLVMSetFunctionCallConv(glofn->llvmvar, LLVMX86StdcallCallConv);
LLVMSetDLLStorageClass(glofn->llvmvar, LLVMDLLImportStorageClass);
LLVMSetVisibility(glofn->llvmvar, LLVMHiddenVisibility);
}
else if(fnname[0] == '_'){
LLVMSetVisibility(glofn->llvmvar, LLVMHiddenVisibility);
}
else if (fnname[0] != '_')
{
//LLVMSetDLLStorageClass(glofn->llvmvar, LLVMDLLExportStorageClass);
LLVMSetVisibility(glofn->llvmvar, LLVMDefaultVisibility);
LLVMSetLinkage(glofn->llvmvar, LLVMExternalLinkage);
}
from cone.
I took a quick pass in committing a code change so that private globals use HiddenVisibility (assuming that if unspecified, the remaining ones will have DefaultVisibility). I did not add the ExternalLinkage, as I am currently unsure that it is needed.
"extern"s (the first if condition) should not be marked with HiddenVisibility, as that defeats the purpose of being able to find and link them in!
I am unable to test the change right now, but if you are, let me know if it works for you.
from cone.
yeah it works. The sad thing is that technically I guess we can't close the issue because it still wouldn't work for executable wasm (wasm with a main method?) according to the docs. Unless that wont be supported by Cone anyway.
from cone.
So long as an executable is linked using the --export-dynamic option, all public globals (including _main) will be exported, so I think we are okay for now. Thanks for picking up this issue and helping so much with its resolution.
from cone.
Related Issues (20)
- Compiler reporting of time is sometimes obviously overestimated HOT 2
- Anonymous function output passed to print HOT 1
- Array declaration fails in global scope HOT 1
- Can't access global variable, as if not seen, but in fact it is seen HOT 2
- Doc for `extern` misses (curly braces) xor (colons) HOT 1
- Fails to print u32 HOT 4
- `typedef` fails HOT 6
- Add support for typed array size HOT 1
- Automatic cast of index when using each HOT 1
- Multidim array type compiles but not usable HOT 2
- Problem with multiple return values HOT 4
- Global arrays are not accessible if not initialized HOT 1
- Literals with underscores not recognized by print and returns HOT 3
- + operator called as a method in backticks does not work or is not implemented HOT 1
- Adding elements to a collection with <- doesn't work HOT 1
- Gist creation broken on the playground
- Grammar railroad diagram HOT 5
- SSL certificate on website invalid since Mar 15, 2022 HOT 2
- Unaccounted for line counting when tokenizing strings HOT 1
- Using C from Cone: calling fopen() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cone.