Skip to contentSkip to conversation

build: various fixes for building with uclibc and libiconv

PATCH Applied Roger Pau Monne 2 participants 8 messages Dec 20, 2011 – Jan 12, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 build: various fixes for building with uclibc and libiconv

This patch contains various fixes to the build system to allow building xen under uclibc with libiconv. Has been tested with uclibc 0.9.32, gcc 4.6.2 and libiconv 1.12, from Alpine Linux 2.3.2.

Changes since v2:

* Added explicit defined(__linux) in bswap.h for both blktap and blktap2.

* Changed the way to check for libiconv presence.

Please review, Roger.

#1 lore raw

PATCH v3 1/1 blktap: remove local definitions and include byteswap.h

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324366300 -3600
# Node ID 32c735e9b6fc6250cb465d091e7fd30d95bf699e # Parent cf68eb390e1bf2fa4bb005ffeccfd41a01c3f81d
blktap: remove local definitions and include byteswap.h

Use the same approach as tools/blktap2/include/libvhd.h, remove local definitions of bswap* and include byteswap.h. Also remove the HAVE_BYTESWAP_H ifdef, since it was not defined in this context (it's defined by QEMU).

tools/blktap/drivers/bswap.h +1 -37
diff -r cf68eb390e1b -r 32c735e9b6fc tools/blktap/drivers/bswap.h
@@ -13,45 +13,9 @@
 #define bswap_16(x) swap16(x)
 #define bswap_32(x) swap32(x)
 #define bswap_64(x) swap64(x)
-#else
+#elif defined(__linux__)
 
-#ifdef HAVE_BYTESWAP_H
 #include <byteswap.h>
-#else
-
-#define bswap_16(x) \
-({ \
-	uint16_t __x = (x); \
-	((uint16_t)( \
-		(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
-		(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
-})
-
-#define bswap_32(x) \
-({ \
-	uint32_t __x = (x); \
-	((uint32_t)( \
-		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
-		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
-		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
-		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
-})
-
-#define bswap_64(x) \
-({ \
-	uint64_t __x = (x); \
-	((uint64_t)( \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
-	        (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
-})
-
-#endif /* !HAVE_BYTESWAP_H */
 
 static inline uint16_t bswap16(uint16_t x)
 {
#2 lore raw

PATCH v3 1/1 blktap2: remove local definitions and include byteswap.h

In reply to Roger Pau Monne

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324366300 -3600
# Node ID 2fd10f2605439da1541646eda7276c8ff390b9de # Parent 32c735e9b6fc6250cb465d091e7fd30d95bf699e
blktap2: remove local definitions and include byteswap.h

Use the same approach as tools/blktap2/include/libvhd.h, remove local definitions of bswap* and include byteswap.h. Also remove the HAVE_BYTESWAP_H ifdef, since it was not defined in this context (it's defined by QEMU).

tools/blktap2/drivers/bswap.h +2 -37
diff -r 32c735e9b6fc -r 2fd10f260543 tools/blktap2/drivers/bswap.h
@@ -13,45 +13,10 @@
 #define bswap_16(x) swap16(x)
 #define bswap_32(x) swap32(x)
 #define bswap_64(x) swap64(x)
-#else
+#elif defined(__linux__)
 
-#ifdef HAVE_BYTESWAP_H
+#include <endian.h>
 #include <byteswap.h>
-#else
-
-#define bswap_16(x) \
-({ \
-	uint16_t __x = (x); \
-	((uint16_t)( \
-		(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
-		(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
-})
-
-#define bswap_32(x) \
-({ \
-	uint32_t __x = (x); \
-	((uint32_t)( \
-		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
-		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
-		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
-		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
-})
-
-#define bswap_64(x) \
-({ \
-	uint64_t __x = (x); \
-	((uint64_t)( \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
-	        (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
-		(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
-})
-
-#endif /* !HAVE_BYTESWAP_H */
 
 static inline uint16_t bswap16(uint16_t x)
 {
#3 lore raw

PATCH v3 1/1 build: detect is libiconv is present

In reply to Roger Pau Monne

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324366300 -3600
# Node ID 023519bfc8964ba9de3521b458d05baa9c8bf4e0 # Parent 2fd10f2605439da1541646eda7276c8ff390b9de
build: detect is libiconv is present

Detect if libiconv is present in the system, since we will have to link against it when using iconv.

Config.mk +5 -0
diff -r 2fd10f260543 -r 023519bfc896 Config.mk
@@ -181,6 +181,11 @@ CHECK_INCLUDES = $(EXTRA_INCLUDES) $(PRE
 EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all
 EMBEDDED_EXTRA_CFLAGS += -fno-exceptions
 
+CONFIG_LIBICONV   := $(shell export OS="`uname -s`"; \
+                       export CHECK_LIB="$(CHECK_LIB)"; \
+                       . $(XEN_ROOT)/tools/check/funcs.sh; \
+                       has_lib libiconv.so && echo 'y' || echo 'n')
+
 # Enable XSM security module (by default, Flask).
 XSM_ENABLE ?= n
 FLASK_ENABLE ?= $(XSM_ENABLE)
#4 lore raw

PATCH v3 1/1 blktap2/vhd: add -liconv when linking if using libiconv

In reply to Roger Pau Monne

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1324366300 -3600
# Node ID f72b99fccfca694674259cc1c03c526a827b67ec # Parent 023519bfc8964ba9de3521b458d05baa9c8bf4e0 blktap2/vhd: add -liconv when linking if using libiconv

If libiconv is detected on the system add -liconv when linking the libvhd library.

If -liconv is not added when compiling libvhd with libiconv the following error occours when linking vhd-util and vhd-update:

gcc -o vhd-util vhd-util.o -Llib -lvhd
lib/libvhd.so: undefined reference to libiconv_open' lib/libvhd.so: undefined reference to libiconv_close' lib/libvhd.so: undefined reference to `libiconv'

tools/blktap2/vhd/lib/Makefile +4 -0
diff -r 023519bfc896 -r f72b99fccfca tools/blktap2/vhd/lib/Makefile
@@ -23,6 +23,10 @@ ifeq ($(CONFIG_Linux),y)
 LIBS            := -luuid
 endif
 
+ifeq ($(CONFIG_LIBICONV),y)
+LIBS            += -liconv
+endif
+
 LIB-SRCS        := libvhd.c
 LIB-SRCS        += libvhd-journal.c
 LIB-SRCS        += vhd-util-coalesce.c
Applied
#5 lore raw
In reply to Roger Pau Monne

Roger Pau Monne writes ("[Xen-devel] [PATCH 0 of 4 v3] build: various fixes for building with uclibc and libiconv"):

Quoted 3 lines

This patch contains various fixes to the build system to allow building xen under uclibc with libiconv. Has been tested with uclibc 0.9.32, gcc 4.6.2 and libiconv 1.12, from Alpine Linux 2.3.2.

Applied all four, thanks.

Ian.

#6 lore raw

2012/1/10 Ian Jackson <[email protected]>:

Quoted 6 lines

Roger Pau Monne writes ("[Xen-devel] [PATCH 0 of 4 v3] build: various fixes for building with uclibc and libiconv"):

Quoted 3 lines

This patch contains various fixes to the build system to allow building xen under uclibc with libiconv. Has been tested with uclibc 0.9.32, gcc 4.6.2 and libiconv 1.12, from Alpine Linux 2.3.2.

Applied all four, thanks.

I was waiting to rework #3 once we had a working configure, but thanks anyway. I will remove the CONFIG_LIBICONV once the configure script is in.

Quoted 2 lines

Ian.

#7 lore raw

Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 0 of 4 v3] build: various fixes for building with uclibc and libiconv"):

Quoted 6 lines

2012/1/10 Ian Jackson <[email protected]>:

Quoted 1 line

Applied all four, thanks.

I was waiting to rework #3 once we had a working configure, but thanks anyway. I will remove the CONFIG_LIBICONV once the configure script is in.

Right, that's what I was expecting, thanks. I didn't think the configure stuff ought to be on the critical path for the libiconv fix.

Ian.