From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.200.46.61 with SMTP id r58mr4023355qta.7.1470860304981; Wed, 10 Aug 2016 13:18:24 -0700 (PDT) X-Received: by 10.157.16.85 with SMTP id o21mr633288oto.0.1470860304927; Wed, 10 Aug 2016 13:18:24 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!j37no7801781qta.0!news-out.google.com!d130ni31079ith.0!nntp.google.com!f6no8953259ith.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 10 Aug 2016 13:18:24 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:1205:c68c:9d90:7db8:f9a:a8fd:5638; posting-account=Pm0FhgoAAAAiPscNT3etSZ15tHNZGXm_ NNTP-Posting-Host: 2a02:1205:c68c:9d90:7db8:f9a:a8fd:5638 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: How to kill GNAT DLL initialization? From: ahlan.marriott@gmail.com Injection-Date: Wed, 10 Aug 2016 20:18:24 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:31369 Date: 2016-08-10T13:18:24-07:00 List-Id: On Wednesday, 10 August 2016 14:52:33 UTC+2, Dmitry A. Kazakov wrote: > As it seems GNAT DLL may not have initialization code invoked in > DllMain. This inevitable deadlocks RTS. Removing user library-level > tasks does not help. The RTS itself contains library-level tasks. E.g. > when asynchronous select is used. > > Now the question is how to kill calls to initialization code from DllMain. > > for Library_Auto_Init use "false"; > > Is not enough. Are there other attributes I missed? > > (Maybe there is a way to remove DllMain from the external symbols list > during linking?) > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de Dear Dmitry, We produce DLLs written using GNAT that are used by other languages - typically C++ We don't explicitly run any initialisation code, the main procedure is always empty. (although this is probably a left over from our ObjectAda days) If something has to be initialised then we put this into a procedure, export it and request that our C++ user calls this before calling any other routine. Here is a typical Gpr file for one of our Dlls. ------- project Monitor is package Naming is for Casing use "mixedcase"; end Naming; for Library_Name use "Monitor"; for Shared_Library_Prefix use ""; for Source_Dirs use ("W:\Source\Ada\Interfaces\Monitor", "W:\Source\Ada\Interfaces", "W:\Source\Ada\Shared", "W:\Source\Ada\Open\Shared", "W:\Source\Ada\Open\Shared\Windows"); for Library_Interface use ("Monitor_Interface"); for Object_Dir use "objects"; for Library_Options use ("-LW:\Product\Windows", "resources.o"); for Library_Dir use "W:\Product\Windows"; for Library_Ali_Dir use "D:\Binary\Ada\Interfaces\Monitor"; for Library_Kind use "dynamic"; for Library_Standalone use "encapsulated"; package Pretty_Printer is for Default_Switches ("ada") use ("-i2", "-M120", "-aL", "-A1", "-A4"); end Pretty_Printer; package Builder is for Default_Switches ("ada") use ("-s", "-g"); end Builder; package Compiler is for Default_Switches ("ada") use ("-O1", "-gnatQ", "-gnata", "-gnato", "-g", "-gnat12", "-gnatwcehijkmopruvz.c.n.p.t.w.x", "-gnatykmpM120"); end Compiler; package Binder is for Default_Switches ("ada") use ("-E"); end Binder; end Monitor; ------- and the main package. ------- with Monitor_Interface; --> UD: Drag in Code procedure Monitor is begin null; end Monitor; ------- Monitor_Interface ads exports all the procedures that the DLL provides and the Adb implements them. Hoping this helps, MfG Ahlan