From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Elaboration code, aggregates Date: Sun, 28 Mar 2021 20:41:25 +0100 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cancel-Lock: sha1:BQRyQoIkRRdDHz5dbcqF8KP31Q0= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:61662 List-Id: In June 2020, Luke A. Guest was having trouble with getting the compiler to place constant data into the data section without elaboration code. https://groups.google.com/g/comp.lang.ada/c/B2NA-qjCJuM/m/4ykywZWZAgAJ During preliminary work for FSF GCC 11, I found that this ARM interrupt vector (which used to compile happily without needing elaboration code) no longer would: https://github.com/simonjwright/cortex-gnat-rts/blob/master/stm32f4/adainclude/startup.adb#L231 Vectors : array (-14 .. Ada.Interrupts.Names.FPU_IRQ) of Handler := (-9 .. -6 | -4 .. -3 => null, -- reserved -14 => Dummy_Handler'Access, -- NMI -13 => HardFault_Handler'Access, -- HardFault -12 => Dummy_Handler'Access, -- MemManagement -11 => Dummy_Handler'Access, -- BusFault -10 => Dummy_Handler'Access, -- UsageFault -5 => SVC_Handler'Access, -- SVCall -2 => PendSV_Handler'Access, -- PendSV -1 => SysTick_Handler'Access, -- SysTick others => IRQ_Handler'Access) with Export, Convention => Ada, External_Name => "isr_vector"; pragma Linker_Section (Vectors, ".isr_vector"); and Arduino Due clock startup ddn't: https://github.com/simonjwright/cortex-gnat-rts/blob/master/arduino-due/adainclude/startup-set_up_clock.adb#L48 PMC_Periph.CKGR_MOR := (KEY => 16#37#, MOSCXTEN => 1, -- main crystal oscillator enable MOSCRCEN => 1, -- main on-chip rc osc. enable MOSCXTST => 8, -- startup time others => <>); On investigating, it turns out that FSF GCC 11 **AND** GNAT CE 2020 have lost the ability to assign aggregates as a whole; instead, they assign the record components one-by-one. The reason for the Arduino Due failure is that the PMC hardware requires that each write to the CKGR_MOR register contain that value of KEY! so the sequence is read the register (KEY is always returned as 0) overwrite the KEY field write the register back read the register, KEY is 0 overwrite the MOSCXTEN field write the register back, KEY is 0 so inoperative etc (including the 'others => <>' components). Bug report raised: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99802