Skip to contentSkip to conversation

Patch for libselinux to build correctly on Sparc.

PATCH Daniel J Walsh 2 participants 2 messages Sep 24, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

https://bugzilla.redhat.com/show_bug.cgi?id=199367

sparc64 needs to use CFLAGS with CC to link properly using gcc the attached patch fixes this issue

Patch submitted originally by Dennis Gilmore.

Further info from bugzilla.

(In reply to comment #7)

Quoted 1 line

It's ok by me, although I'm wondering what CFLAGS you are supplying

that matter

Quoted 1 line

here.

For multilib support, sparc needs libselinux (and libsepol) to be built as sparc
(32bit) and sparc64 (64bit). sparc builds fine (-m32 is assumed by the compiler), but when building for sparc64, we need all compile and link operations to have -m64 passed for it, or else gcc will mismatch (it will make
sparc64 object files, then try to link them as a 32bit library) and the build fails.

The easiest way to ensure safe and consistent builds is to universally apply CFLAGS whenever calling CC, which is what this patch does. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFG9926rlYvE4MpobMRAuguAKDBxJbz4hV3khmgHFYRiPYCuSS8qACeJUJv 99nyoIM2VK6cbzR/9xlNHwA=
=htQu
-----END PGP SIGNATURE-----

src/Makefile +2 -2
diff --exclude-from=exclude -N -u -r nsalibselinux/src/Makefile libselinux-2.0.34/src/Makefile
@@ -57,10 +57,10 @@
 	$(CC) $(CFLAGS) -I$(PYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(SWIGSO): $(SWIGLOBJ)
-	$(CC) $(LDFLAGS) -shared -o $@ $< -L. -lselinux -L$(LIBDIR) -Wl,-soname,$@
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lselinux -L$(LIBDIR) -Wl,-soname,$@
 
 $(LIBSO): $(LOBJS)
-	$(CC) $(LDFLAGS) -shared -o $@ $^ -ldl -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -ldl -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
 	ln -sf $@ $(TARGET) 
 
 %.o:  %.c policy.h
#1 lore raw
Quoted 27 lines · Daniel J Walsh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

https://bugzilla.redhat.com/show_bug.cgi?id=199367

sparc64 needs to use CFLAGS with CC to link properly using gcc the attached patch fixes this issue

Patch submitted originally by Dennis Gilmore.

Further info from bugzilla.

(In reply to comment #7)

Quoted 1 line

It's ok by me, although I'm wondering what CFLAGS you are supplying

that matter

Quoted 1 line

here.

For multilib support, sparc needs libselinux (and libsepol) to be built as sparc
(32bit) and sparc64 (64bit). sparc builds fine (-m32 is assumed by the compiler), but when building for sparc64, we need all compile and link operations to have -m64 passed for it, or else gcc will mismatch (it will make
sparc64 object files, then try to link them as a 32bit library) and the build fails.

Quoted 2 lines

The easiest way to ensure safe and consistent builds is to universally apply CFLAGS whenever calling CC, which is what this patch does.

Thanks, also applied patch below to do the same for libsepol and libsemanage.

src/Makefile +2 -2
Index: libsemanage/src/Makefile
===================================================================
@@ -47,14 +47,14 @@
 	$(CC) $(CFLAGS) -I$(PYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(SWIGSO): $(SWIGLOBJ)
-	$(CC) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage -l$(PYLIBVER) -L$(LIBDIR) -Wl,-soname,$@,-z,defs
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage -l$(PYLIBVER) -L$(LIBDIR) -Wl,-soname,$@,-z,defs
 
 $(LIBA): $(OBJS)
 	$(AR) rcs $@ $^
 	ranlib $@
 
 $(LIBSO): $(LOBJS)
-	$(CC) $(LDFLAGS) -shared -o $@ $^ -lsepol -lselinux -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -lselinux -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
 	ln -sf $@ $(TARGET)
 
 conf-scan.c: conf-scan.l conf-parse.h
src/Makefile +1 -1
Index: libsepol/src/Makefile
===================================================================
@@ -20,7 +20,7 @@
 	ranlib $@
 
 $(LIBSO): $(LOBJS)
-	$(CC) $(LDFLAGS) -shared -o $@ $^ -Wl,-soname,$(LIBSO),--version-script=libsepol.map,-z,defs
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -Wl,-soname,$(LIBSO),--version-script=libsepol.map,-z,defs
 	ln -sf $@ $(TARGET) 
 
 %.o:  %.c 
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.