Subject: gcc-3.4 optimization kills "link sets"
To: None <tech-toolchain@netbsd.org, tech-kern@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-kern
Date: 06/07/2004 18:43:57
This is a multipart MIME message.
--==_Exmh_3052546149690
Content-Type: text/plain; charset=us-ascii
Trying to build a kernel with gcc-3.4 I've found that the
optimisation settings of the current default kernel Makefile
cause unreferenced static variables to be optimized away,
regardless of an __attribute__((unused)).
This breaks the "link set" way of initializing arrays of
things which are scattered around.
Rather than introducing dummy references to trick gcc into
keeping definitions in it would look cleaner to just make
these definitions global -- see the appended patch.
Are ther any possible conflicts or side-effects?
best regards
Matthias
--==_Exmh_3052546149690
Content-Type: text/plain ; name="linkset.txt"; charset=us-ascii
Content-Description: linkset.txt
Content-Disposition: attachment; filename="linkset.txt"
Index: sys/sys/cdefs_elf.h
===================================================================
RCS file: /cvsroot/src/sys/sys/cdefs_elf.h,v
retrieving revision 1.20
diff -u -r1.20 cdefs_elf.h
--- sys/sys/cdefs_elf.h 6 Jun 2004 01:36:25 -0000 1.20
+++ sys/sys/cdefs_elf.h 7 Jun 2004 17:35:44 -0000
@@ -118,10 +118,10 @@
#ifndef __lint__
#define __link_set_make_entry(set, sym) \
- static void const * const __link_set_##set##_sym_##sym \
+ void const * const __link_set_##set##_sym_##sym \
__section("link_set_" #set) __unused = &sym
#define __link_set_make_entry2(set, sym, n) \
- static void const * const __link_set_##set##_sym_##sym##_##n \
+ void const * const __link_set_##set##_sym_##sym##_##n \
__section("link_set_" #set) __unused = &sym[n]
#else
#define __link_set_make_entry(set, sym) \
--==_Exmh_3052546149690--