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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: gnat compiler issues with a partial build Date: Wed, 10 Jun 2015 17:59:29 +0100 Organization: A noiseless patient Spider Message-ID: References: <6d5f352b-d886-4cd4-8f88-4116fe34129a@googlegroups.com> <4bc35d01-158d-48bb-b241-d4e3c3ce4344@googlegroups.com> <373a8c7e-8538-4de3-9647-dead707b8a88@googlegroups.com> <1e1e5cf8-5535-4e9f-9d85-261466ad9ce2@googlegroups.com> <295e0eb8-4779-4c72-ba98-3fb0c507640d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="2c7d8f71a176d2eaa78ec9fbd86e1d4a"; logging-data="10343"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jZ27TjgtxOglneecPW4HVRMAgH/PpQes=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:xcEPNp0gyXbBxnrCe8/mzg6G9nY= sha1:DXWMGcCaM1N+vK/D3D6Cm/miK0w= Xref: number.nntp.giganews.com comp.lang.ada:193562 Date: 2015-06-10T17:59:29+01:00 List-Id: jan.de.kruyf@gmail.com writes: > In any case: the runtime cooking business is like this (in its most > basic form) > 1. extract something very basic from ravenscar or zfp. > 2. compile little test programs with (1) in a subdirectory and no libraries. > 3. run nm to look for 'U' symbols. and use grep to find where they > originate and where they are defined in any runtime. > 4. Then adapt that piece of code where they are defined, one way or > another, to you new runtime. > Normally of course either ravenscar or zfp will have a piece of > code that fits without hacking too much. > only for heap memory I had to modify s-memory quite a bit to fit the > kernel environment so it is all strictly controlled and not > pageable. (one of my requirements) > 5. repeat 2,3,4 until satisfied that it is usable now. Then you can > build the runtime subdirectory into a runtime library. > > So in that process I discovered those pesky undefined symbols, that > _should_ disappear with some compiler switch, either in System.ads or > on the command line. Since it is superfluous code that is generated by > the compiler, for which there are no symbols in the arm ravenscar > profile, that I am sure of. The compiler needs to know that it's compiling against a runtime system, which is a complete set of Ada units for your purposes. This means it won't look anywhere else for units it needs. You could try a structure like top/kernel/adainclude /adalib /proj kernel will be your RTS, adainclude is where the Ada source goes, adalib is where the library and ALI files end up. adainclude and adalib are the default names; don't use anything else or it won't be recognised as an RTS (there are some bells & whistles here, not needed to start with). proj is where your test code goes. In kernel you need a GPR file to build the RTS. I'm not sure what the minimum needed is, but looking at the one I use in the STM32F4 RTS, it'll be something like library project Build_Runtime is for Library_Name use "gnat"; for Library_Kind use "static"; -- Results in libgnat.a. This should be OK since the RTS will be -- linked into your module. for Library_Dir use "adalib"; for Object_Dir use ".build"; for Source_Dirs use ("adainclude"); package Builder is -- An RTS that has built with this package will build without -- it; it may prevent picking up missing units from your -- host compiler's RTS; that may also be why -nostdinc is in -- ADAFLAGS below for Switches ("Ada") use ("--RTS=" & Project'Project_Dir); end Builder; package Compiler is ADAFLAGS := ("-gnatpgn", "-gnatqQ", "-O2", "-nostdinc"); -- Do you need -fpic or -fPIC? probably -- I'm not sure about the -nostdinc here for Switches ("Ada") use ADAFLAGS; end Compiler; end Build_Runtime; As I said, your source files go in kernel/adainclude. I don't know about gnat.adc; what I (and AdaCore) have done is put all the restrictions in package System, seems to work just fine barring compiler errors. You need to be careful about the Ada features you use in the RTS. Stick to Ada95, only include packages under Ada, Interfaces, and GNAT. Strongly recommend doing all your builds with gprbuild rather than gnatmake; if you have any C or C++ code, you must use gprbuild. To test out your RTS, use code in the proj directory, and a project file. You can say gprbuild --RTS=../kernel -P foo.gpr or you can include this in foo.gpr: package Builder is for Default_Switches ("ada") use ("--RTS=../kernel"); end Builder; It's possible you might need an absolute path to find the RTS.