Re: Problem with coupling shared object symbol visibility with protection

2015-02-18 Thread Andre via Digitalmars-d
Hi, I also want to say a big thank you to all of you involved in this topic and especially to Benjamin. Proper DLL handling in D I would really appreciate. I think this topic is the break through. Kind regards André On Tuesday, 17 February 2015 at 18:03:06 UTC, Benjamin Thaut wrote: So i

Re: Problem with coupling shared object symbol visibility with protection

2015-02-18 Thread Dicebot via Digitalmars-d
On Monday, 16 February 2015 at 20:19:27 UTC, Jacob Carlborg wrote: On 2015-02-16 10:40, Benjamin Thaut wrote: This is in fact not a breaking change because export is broken anyway. Due to bug 922 export can't be used in cross platform libraries. I haven't seen a single library on dub that

Re: Problem with coupling shared object symbol visibility with protection

2015-02-17 Thread Benjamin Thaut via Digitalmars-d
So i looked at the Dll Test within the dmd test framework and when I make export an attribute, like I suggested, this perticular test will compile run without any code changes. This is another reason why I suspect that making export an attribute will only break very little if any code at all.

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Jacob Carlborg via Digitalmars-d
On 2015-02-16 10:40, Benjamin Thaut wrote: This is in fact not a breaking change because export is broken anyway. Due to bug 922 export can't be used in cross platform libraries. I haven't seen a single library on dub that uses export (most likely for exactly that reason). Most likely due to

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Walter Bright via Digitalmars-d
On 2/16/2015 12:19 PM, Jacob Carlborg wrote: Most likely due to that the support for dynamic libraries is fairly new only works on Linux (?). Part of the test suite creates a DLL using D for Windows.

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Joakim via Digitalmars-d
On Monday, 16 February 2015 at 21:41:00 UTC, Walter Bright wrote: On 2/16/2015 12:19 PM, Jacob Carlborg wrote: Most likely due to that the support for dynamic libraries is fairly new only works on Linux (?). Part of the test suite creates a DLL using D for Windows. Martin recently added

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Walter Bright via Digitalmars-d
On 1/31/2015 11:52 AM, Benjamin Thaut wrote: @Walter: Making export a attribute seems to be the preferred choice in this discussion. Additionaly this was the result of the last discussion around export, a year ago, although for different reasons. The last Discussion resulted in DIP 45 which also

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Dicebot via Digitalmars-d
On Monday, 16 February 2015 at 08:08:17 UTC, Walter Bright wrote: On 1/31/2015 11:52 AM, Benjamin Thaut wrote: @Walter: Making export a attribute seems to be the preferred choice in this discussion. Additionaly this was the result of the last discussion around export, a year ago, although for

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Benjamin Thaut via Digitalmars-d
On Monday, 16 February 2015 at 08:08:17 UTC, Walter Bright wrote: At this point I suggest simply making those private helper functions public and export them. It gets your project moving without waiting for language changes (and this is a breaking change). This is in fact not a breaking

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Benjamin Thaut via Digitalmars-d
On Monday, 16 February 2015 at 09:59:07 UTC, Walter Bright wrote: -- Here is a list of all things wrong with export: 32 64 bit issues: 1) Exporting a global variable leads to a linker error 2) Exporting thread local variables should be an error (at least it is in c++) 3) The module

Re: Problem with coupling shared object symbol visibility with protection

2015-02-16 Thread Walter Bright via Digitalmars-d
On 2/16/2015 1:40 AM, Benjamin Thaut wrote: On Monday, 16 February 2015 at 08:08:17 UTC, Walter Bright wrote: At this point I suggest simply making those private helper functions public and export them. It gets your project moving without waiting for language changes (and this is a breaking

Re: Problem with coupling shared object symbol visibility with protection

2015-02-01 Thread Dicebot via Digitalmars-d
On Sunday, 1 February 2015 at 09:24:46 UTC, Benjamin Thaut wrote: So you'd want bar to be duplicated on both sides ? This is gonna cause problems with di files. No. He wants the compiler to automatically detect that the template foo might call bar. As a result the compiler should export bar

Re: Problem with coupling shared object symbol visibility with protection

2015-02-01 Thread Benjamin Thaut via Digitalmars-d
Am 31.01.2015 um 23:42 schrieb deadalnix: On Wednesday, 28 January 2015 at 13:48:45 UTC, Dicebot wrote: Isn't that what your first proposed solution is about? That was my understanding and I liked that understanding :) To be 100% clear : export void foo(T : int)(T x) { bar(x); } private

Re: Problem with coupling shared object symbol visibility with protection

2015-01-31 Thread Benjamin Thaut via Digitalmars-d
Am 31.01.2015 um 06:11 schrieb Dicebot: On Friday, 30 January 2015 at 19:10:06 UTC, Martin Nowak wrote: It has a serious drawback of increasing attribute noise even more though. First approach allows for more automatic inference. But with D restrictions it seems the least bad option. Well,

Re: Problem with coupling shared object symbol visibility with protection

2015-01-31 Thread Benjamin Thaut via Digitalmars-d
Am 31.01.2015 um 13:07 schrieb Martin Nowak: That's probably how it should behave, though an attribute applying only to public members unless explicitly added is unprecedented. Still seems like the right choice here, but might require some additional compiler logic. Well you don't have to

Re: Problem with coupling shared object symbol visibility with protection

2015-01-31 Thread deadalnix via Digitalmars-d
On Wednesday, 28 January 2015 at 13:48:45 UTC, Dicebot wrote: Isn't that what your first proposed solution is about? That was my understanding and I liked that understanding :) To be 100% clear : export void foo(T : int)(T x) { bar(x); } private void bar(int x) { } I'd expect `bar` to

Re: Problem with coupling shared object symbol visibility with protection

2015-01-31 Thread Martin Nowak via Digitalmars-d
On Saturday, 31 January 2015 at 09:25:10 UTC, Benjamin Thaut wrote: Well, export is going to remain transitive. So the first approach is still going to work. The only difference is going to be that you can force export private declarations. So for most modules it is hopefully going to be

Re: Problem with coupling shared object symbol visibility with protection

2015-01-30 Thread Martin Nowak via Digitalmars-d
On Tuesday, 20 January 2015 at 12:23:32 UTC, Benjamin Thaut wrote: 2) Make export an attribute. If export is no longer an protection level but instead an attribute this issue can easily be solved by doing. export public void templateFunc(T)() { someHelperFunc(); } export private void

Re: Problem with coupling shared object symbol visibility with protection

2015-01-30 Thread Benjamin Thaut via Digitalmars-d
Am 30.01.2015 um 11:39 schrieb Martin Nowak: If you mean float, then it will instatiate the template when compiled individually and use b's instantiation when b and c are compiled together. If this is true, then please explain this behavior: module a; // -- a.dll struct Storage(T) { T

Re: Problem with coupling shared object symbol visibility with protection

2015-01-30 Thread Dicebot via Digitalmars-d
On Friday, 30 January 2015 at 19:10:06 UTC, Martin Nowak wrote: On Tuesday, 20 January 2015 at 12:23:32 UTC, Benjamin Thaut wrote: 2) Make export an attribute. If export is no longer an protection level but instead an attribute this issue can easily be solved by doing. export public void

Re: Problem with coupling shared object symbol visibility with protection

2015-01-30 Thread Martin Nowak via Digitalmars-d
On Thursday, 29 January 2015 at 13:24:36 UTC, Benjamin Thaut wrote: module c: SomeTemplate!uint var3; // will this use instaction from b? Or instanciate itself? That's the first instantiation with uint. If you mean float, then it will instatiate the template when compiled individually and

Re: Problem with coupling shared object symbol visibility with protection

2015-01-29 Thread Walter Bright via Digitalmars-d
On 1/28/2015 5:19 AM, Benjamin Thaut wrote: On Wednesday, 28 January 2015 at 11:01:09 UTC, Walter Bright wrote: The example had marked the template itself as 'export'. This raises the specter of which binary the template instantiation exists in. The export in this context actually means

Re: Problem with coupling shared object symbol visibility with protection

2015-01-29 Thread Walter Bright via Digitalmars-d
On 1/28/2015 5:27 AM, Benjamin Thaut wrote: Also sorry for the harsh answer, this was a classical double misunderstanding. No problemo.

Re: Problem with coupling shared object symbol visibility with protection

2015-01-29 Thread Benjamin Thaut via Digitalmars-d
On Thursday, 29 January 2015 at 10:21:25 UTC, Walter Bright wrote: On 1/28/2015 5:19 AM, Benjamin Thaut wrote: On Wednesday, 28 January 2015 at 11:01:09 UTC, Walter Bright wrote: The example had marked the template itself as 'export'. This raises the specter of which binary the template

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Dicebot via Digitalmars-d
On Wednesday, 28 January 2015 at 14:16:03 UTC, Benjamin Thaut wrote: Well this would be ultimate goal. Although it is not possible to automatically detect that bar needs to be exported because that would mean you would have to analyze all possible instantiations of the template foo. (static

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Dicebot via Digitalmars-d
On Wednesday, 28 January 2015 at 13:30:17 UTC, Benjamin Thaut wrote: On Wednesday, 28 January 2015 at 11:42:19 UTC, Dicebot wrote: 2) first proposed solution does not allow to mark private functions as export. It implicitly exports those if they are needed for actual public/export template

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Benjamin Thaut via Digitalmars-d
On Wednesday, 28 January 2015 at 11:01:09 UTC, Walter Bright wrote: The example had marked the template itself as 'export'. This raises the specter of which binary the template instantiation exists in. Also sorry for the harsh answer, this was a classical double misunderstanding.

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Benjamin Thaut via Digitalmars-d
On Wednesday, 28 January 2015 at 11:01:09 UTC, Walter Bright wrote: The example had marked the template itself as 'export'. This raises the specter of which binary the template instantiation exists in. The export in this context actually means export all instanciations of this template.

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Benjamin Thaut via Digitalmars-d
On Wednesday, 28 January 2015 at 11:42:19 UTC, Dicebot wrote: 2) first proposed solution does not allow to mark private functions as export. It implicitly exports those if they are needed for actual public/export template function to work. This is not the same - those functions still can't

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Benjamin Thaut via Digitalmars-d
On Wednesday, 28 January 2015 at 13:48:45 UTC, Dicebot wrote: Isn't that what your first proposed solution is about? That was my understanding and I liked that understanding :) To be 100% clear : export void foo(T : int)(T x) { bar(x); } private void bar(int x) { } I'd expect `bar` to

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Benjamin Thaut via Digitalmars-d
On Tuesday, 27 January 2015 at 22:29:41 UTC, Rainer Schuetze wrote: I would not mind if we export all symbols on Windows aswell. It doesn't seem to bother a lot of people for the linux version, even though it's unsafer and slower than on Windows (at least that was my experience more than 10

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Dicebot via Digitalmars-d
My 5 cents: 1) export all approach is extremely limiting and I'd like to see it go on Linux too. One of major problems with it is that many forms of link-time optimizations (such as --gc-sections) become simply impossible when compiler can't know what symbols are actually supposed to be

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Walter Bright via Digitalmars-d
On 1/27/2015 2:05 PM, Rainer Schuetze wrote: On 26.01.2015 23:24, Walter Bright wrote: The problem here is that you don't want to make someHelperFunc() export because that would mean users could call it directly, but you want it to be available for cross shared library calls. The cross shared

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Benjamin Thaut via Digitalmars-d
On Wednesday, 28 January 2015 at 14:31:54 UTC, Dicebot wrote: Yes, I see the problem now. static if isn't even the worst offender, any kind of string mixins that generate the call to `bar` are impossible to detect without having actual `foo` instance. Sorry for misinterpretation. With

Re: Problem with coupling shared object symbol visibility with protection

2015-01-28 Thread Dicebot via Digitalmars-d
On Wednesday, 28 January 2015 at 15:01:30 UTC, Benjamin Thaut wrote: With that in mind second option is starting to look more attractive despite the grammar change - forcing good chunk template API into structs does not sound very convenient :( Well and then there is the third option Walter

Re: Problem with coupling shared object symbol visibility with protection

2015-01-27 Thread Rainer Schuetze via Digitalmars-d
On 26.01.2015 23:24, Walter Bright wrote: The problem here is that you don't want to make someHelperFunc() export because that would mean users could call it directly, but you want it to be available for cross shared library calls. The cross shared library call happens if a template is

Re: Problem with coupling shared object symbol visibility with protection

2015-01-27 Thread Rainer Schuetze via Digitalmars-d
On 20.01.2015 13:23, Benjamin Thaut wrote: I'm currently working on Windows DLL support which has stronger rules than linux shared objects for which symbols actually get exported from a shared library. But as we want to replicate the same behaviour on linux using symbol visibility (e.g. gcc 4

Re: Problem with coupling shared object symbol visibility with protection

2015-01-26 Thread Benjamin Thaut via Digitalmars-d
Am 26.01.2015 um 23:24 schrieb Walter Bright: exporting a template and then having the user instantiate outside of the library doesn't make a whole lot of sense, because the instantiation won't be there in the library. The library will have to instantiate every use case. If the compiler knows

Re: Problem with coupling shared object symbol visibility with protection

2015-01-26 Thread Walter Bright via Digitalmars-d
On 1/20/2015 4:23 AM, Benjamin Thaut wrote: I'm currently working on Windows DLL support which has stronger rules than linux shared objects for which symbols actually get exported from a shared library. But as we want to replicate the same behaviour on linux using symbol visibility (e.g. gcc 4

Re: Problem with coupling shared object symbol visibility with protection

2015-01-22 Thread Benjamin Thaut via Digitalmars-d
There are uses in Phobos where workaround 1) would require some code changes: private @property File trustedStdout() @trusted { return stdout; } void write(T...)(T args) if (!is(T[0] : File)) { trustedStdout.write(args); } My workaround so far: export struct _impl1 { package @property

Re: Problem with coupling shared object symbol visibility with protection

2015-01-21 Thread Dicebot via Digitalmars-d
I like the first version more as it fits better the natural way people design their interfaces and reduces attributed noise. Can't say if it will trigger some hidden issues. First version also fits better some of ideas I had about automated API generation/verification

Re: Problem with coupling shared object symbol visibility with protection

2015-01-21 Thread Paulo Pinto via Digitalmars-d
On Tuesday, 20 January 2015 at 12:23:32 UTC, Benjamin Thaut wrote: I'm currently working on Windows DLL support which has stronger rules than linux shared objects for which symbols actually get exported from a shared library. But as we want to replicate the same behaviour on linux using symbol

Re: Problem with coupling shared object symbol visibility with protection

2015-01-21 Thread Benjamin Thaut via Digitalmars-d
Thanks for keeping to poke this issue - symbol visibility is currently a big undefined minefield in D ABI. Your welcome. At this point I'm so desperate for D Dll support that I stopped poking and started implementing it myself. I'm 3 unresolved symbol references away from actually building

Problem with coupling shared object symbol visibility with protection

2015-01-20 Thread Benjamin Thaut via Digitalmars-d
I'm currently working on Windows DLL support which has stronger rules than linux shared objects for which symbols actually get exported from a shared library. But as we want to replicate the same behaviour on linux using symbol visibility (e.g. gcc 4 -fVisibility=hidden) this issue also