Skip to contentSkip to conversation

: Fix fs modules on sparc64 build with newer gcc

PATCH In review David Miller 3 participants 8 messages Apr 11, 2009 – May 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Fix fs modules on sparc64 build with newer gcc

Newer versions of gcc emit references to libgcc internal functions __bswapsi2 and __bswapdi2 when building ufs and some other filesystem modules on sparc64.

Unfortunately older versions of gcc lack these symbols in libgcc so we can't export them universally, we have to check for it using configure link tests.

I commited this under the "trust dave with sparc stuff" rule. Let me know if it that wasn't appropriate in this case :-)

I also rebuild configure when commiting these changes.

Thanks.

2009-04-11 David S. Miller <[email protected]>

* conf/sparc64-ieee1275.rmk (kernel_img_LDFLAGS): Link with static libgcc.
* configure.ac: Check for __bswapsi2 and __bswapdi2 presence.
* include/grub/sparc64/libgcc.h (__bswapsi2): Export libgcc function, if present.
(__bswapdi2): Likewise.

---
 conf/sparc64-ieee1275.rmk     |    2 +-
 configure.ac                  |    2 +-
 include/grub/sparc64/libgcc.h |   12 ++++++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)
conf/sparc64-ieee1275.rmk +1 -1
index 1658a66..f1fdb5b 100644
@@ -81,7 +81,7 @@ kernel_elf_SOURCES = kern/sparc64/ieee1275/init.c kern/ieee1275/ieee1275.c \
 kernel_elf_HEADERS = grub/sparc64/ieee1275/ieee1275.h
 kernel_elf_CFLAGS = $(COMMON_CFLAGS)
 kernel_elf_ASFLAGS = $(COMMON_ASFLAGS)
-kernel_elf_LDFLAGS = -mno-app-regs -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc
+kernel_elf_LDFLAGS = -mno-app-regs -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
 
 # Modules.
 #_linux.mod linux.mod
configure.ac +1 -1
index 134e0a3..69f9783 100644
@@ -200,7 +200,7 @@ if test "$target_cpu"-"$platform" = i386-pc; then
 fi
 
 # Check for functions.
-AC_CHECK_FUNCS(posix_memalign memalign asprintf)
+AC_CHECK_FUNCS(posix_memalign memalign asprintf __bswapsi2 __bswapdi2)
 
 #
 # Check for target programs.
include/grub/sparc64/libgcc.h +12 -0
index e30c717..4a6b619 100644
@@ -16,4 +16,16 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
+
 void EXPORT_FUNC (memset) (void);
+
+#ifdef HAVE___BSWAPSI2
+typedef int SItype __attribute__ ((mode (SI)));
+SItype EXPORT_FUNC (__bswapsi2) (SItype);
+#endif
+
+#ifdef HAVE___BSWAPDI2
+typedef int DItype __attribute__ ((mode (DI)));
+DItype EXPORT_FUNC (__bswapdi2) (DItype);
+#endif
Signature · 1 line
1.6.2.1.222.g570cc
#1 lore raw
Quoted 10 lines · David Miller

Newer versions of gcc emit references to libgcc internal functions __bswapsi2 and __bswapdi2 when building ufs and some other filesystem modules on sparc64.

Unfortunately older versions of gcc lack these symbols in libgcc so we can't export them universally, we have to check for it using configure link tests.

I commited this under the "trust dave with sparc stuff" rule. Let me know if it that wasn't appropriate in this case :-)

Actually, changes to configure.ac affect other users as well. Users of other architectures would have to run those checks.

I would try to use weak functions or something like that. Failing that, I would add a check for affected architectures only. Even if that would make the script longer, it would make it clear which architectures need the check, which is probably a good idea.

Quoted 1 line

I also rebuild configure when commiting these changes.

I see that configure and config.h.in we built by different versions of autoconf. That's likely to break.

I would run autogen.sh and commit all changed files after examining the changes. As a courtesy to others, I install the same version of Autoconf that the current configure script was generated with.

Adding or removing files means that DISTLIST will change. That should be committed as well.

Personally, I would remove all files generated by autogen.sh from the repository. But I don't want to do something that is inconvenient to others. The issue was discussed in the past and the decision was to keep those files.

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw

From: Pavel Roskin <[email protected]>
Date: Sat, 11 Apr 2009 23:53:33 -0400

Quoted 9 lines · David Miller
Quoted 8 lines

Newer versions of gcc emit references to libgcc internal functions __bswapsi2 and __bswapdi2 when building ufs and some other filesystem modules on sparc64.

Unfortunately older versions of gcc lack these symbols in libgcc so we can't export them universally, we have to check for it using configure link tests.

Quoted 5 lines
Quoted 2 lines

I commited this under the "trust dave with sparc stuff" rule. Let me know if it that wasn't appropriate in this case :-)

Actually, changes to configure.ac affect other users as well. Users of other architectures would have to run those checks.

And what kind of problems would that cause? The symbols would not be found, the test wouldn't pass, and other platforms don't use the resulting config.h defines as well. Only the sparc64 build uses this stuff.

It seems entirely harmless.

Quoted 4 lines

I would try to use weak functions or something like that. Failing that, I would add a check for affected architectures only. Even if that would make the script longer, it would make it clear which architectures need the check, which is probably a good idea.

I don't think that would work well, these are symbols we have to export to modules.

And since as I described above the test and the config.h defines are totally harmless to other targets, I don't see what the point is in using a more complicated and indirect implementation.

Quoted 11 lines
Quoted 1 line

I also rebuild configure when commiting these changes.

I see that configure and config.h.in we built by different versions of autoconf. That's likely to break.

I would run autogen.sh and commit all changed files after examining the changes. As a courtesy to others, I install the same version of Autoconf that the current configure script was generated with.

Adding or removing files means that DISTLIST will change. That should be committed as well.

I always check the status of my tree after running autogen.sh so I would take care of all of these things.

#3 lore raw
Quoted 7 lines · David Miller
Quoted 2 lines

Actually, changes to configure.ac affect other users as well. Users of other architectures would have to run those checks.

And what kind of problems would that cause? The symbols would not be found, the test wouldn't pass, and other platforms don't use the resulting config.h defines as well. Only the sparc64 build uses this stuff.

The only problem that it will slow down the configure script.

By the way, the checks for those functions should be done with the target compiler, that is after the second occurrence of CC="$TARGET_CC" in configure.ac.

Quoted 2 lines

I always check the status of my tree after running autogen.sh so I would take care of all of these things.

OK, I don't want to search who did it. I hope we'll get rid of this annoyance soon.

Signature · 2 lines
Regards,
Pavel Roskin
#4 lore raw

From: Pavel Roskin <[email protected]>
Date: Sun, 12 Apr 2009 17:19:42 -0400

Quoted 11 lines · David Miller
Quoted 8 lines
Quoted 3 lines

Actually, changes to configure.ac affect other users as well. Users of other architectures would have to run those checks.

And what kind of problems would that cause? The symbols would not be found, the test wouldn't pass, and other platforms don't use the resulting config.h defines as well. Only the sparc64 build uses this stuff.

The only problem that it will slow down the configure script.

This is not a serious issue. The configure run is very compact and efficient and my changes aren't going to materially change this in any way whatsoever.

Quoted 3 lines

By the way, the checks for those functions should be done with the target compiler, that is after the second occurrence of CC="$TARGET_CC" in configure.ac.

Sure, I can fix that.

#5 lore raw
Quoted 5 lines · David Miller
Quoted 1 line

The only problem that it will slow down the configure script.

This is not a serious issue. The configure run is very compact and efficient and my changes aren't going to materially change this in any way whatsoever.

I know. Although my PowerMAC G3 is slow enough, and I would hate to see it run checks it doesn't need.

Quoted 5 lines
Quoted 3 lines

By the way, the checks for those functions should be done with the target compiler, that is after the second occurrence of CC="$TARGET_CC" in configure.ac.

Sure, I can fix that.

Thanks!

Signature · 2 lines
Regards,
Pavel Roskin
#6 lore raw

From: Pavel Roskin <[email protected]>
Date: Mon, 13 Apr 2009 01:06:49 -0400

Quoted 9 lines · David Miller
Quoted 6 lines
Quoted 4 lines

By the way, the checks for those functions should be done with the target compiler, that is after the second occurrence of CC="$TARGET_CC" in configure.ac.

Sure, I can fix that.

Thanks!

I've committed this fix.

#7 lore raw
In reply to David Miller

configure.ac if test "$target_cpu"-"$platform" = i386-pc; then

Quoted 13 lines · David Miller
configure.ac +5 -1
@@ -200,7 +200,7 @@ if test "$target_cpu"-"$platform" = i386-pc; then
 fi
 
 # Check for functions.
-AC_CHECK_FUNCS(posix_memalign memalign asprintf)
+AC_CHECK_FUNCS(posix_memalign memalign asprintf __bswapsi2 __bswapdi2)
[...]
+#ifdef HAVE___BSWAPSI2
+typedef int SItype __attribute__ ((mode (SI)));
+SItype EXPORT_FUNC (__bswapsi2) (SItype);
+#endif

Very nice. I wish someone with a powerpc and some spare time would do the same to include/grub/powerpc/libgcc.h ;-)

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."