Discussion:
[edk2] [PATCH] BaseTools: Fix build on FreeBSD and allow use of non-gcc system compiler
Bruce Cran
2015-07-07 10:14:44 UTC
Permalink
On FreeBSD, uuid.h is in /usr/include, not /usr/include/uuid.

Fix some errors when building using clang caused by self-assignment: the
preferred way to 'use' a variable is '(void)x;', not 'x = x;'.

Where the system provides $(CC) etc. by default, don't override it to be gcc.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bruce Cran <***@cran.org.uk>
---
BaseTools/Source/C/GenFv/GenFvInternalLib.c | 7 ++++++-
BaseTools/Source/C/LzmaCompress/LzmaCompress.c | 4 ++--
BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 2 +-
BaseTools/Source/C/Makefiles/header.makefile | 10 +++++-----
BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 2 +-
5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index ed9d496..0050985 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -16,8 +16,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Include files
//
-#ifdef __GNUC__
+
+#if defined(__FreeBSD__)
+#include <uuid.h>
+#elif defined(__GNUC__)
#include <uuid/uuid.h>
+#endif
+#ifdef __GNUC__
#include <sys/stat.h>
#endif
#include <string.h>
diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
index b569b4e..1de07a3 100644
--- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
+++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
@@ -43,8 +43,8 @@ const char *kCantWriteMessage = "Can not write output file";
const char *kCantAllocateMessage = "Can not allocate memory";
const char *kDataErrorMessage = "Data error";

-static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
-static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static void *SzAlloc(void *p, size_t size) { (void)p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) { (void)p; MyFree(address); }
static ISzAlloc g_Alloc = { SzAlloc, SzFree };

static Bool mQuietMode = False;
diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
index 7272272..95c3c9f 100644
--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
@@ -2112,7 +2112,7 @@ void LzmaEnc_Finish(CLzmaEncHandle pp)
if (p->mtMode)
MatchFinderMt_ReleaseStream(&p->matchFinderMt);
#else
- pp = pp;
+ (void)pp;
#endif
}

diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index 6a759d9..09d2bff 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -21,11 +21,11 @@ CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
LINUX:=$(findstring Linux, $(shell uname -s))
DARWIN:=$(findstring Darwin, $(shell uname -s))

-CC = gcc
-CXX = g++
-AS = gcc
-AR = ar
-LD = ld
+CC ?= gcc
+CXX ?= g++
+AS ?= gcc
+AR ?= ar
+LD ?= ld
LINKER ?= $(CC)
ifeq ($(ARCH), IA32)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
index 478a3a1..c49cfd8 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
@@ -164,7 +164,7 @@ PCCTS_H=../h
#
# UNIX (default)
#
-CC=gcc
+CC?=gcc
COPT=-O
ANTLR=${BIN_DIR}/antlr
DLG=${BIN_DIR}/dlg
--
2.4.5
Liu, Yingke D
2015-07-08 01:07:58 UTC
Permalink
Reviewed-by: Yingke Liu <***@intel.com>

Thanks for your patch, it was committed at revision 17866.

Dennis

-----Original Message-----
From: Bruce Cran [mailto:***@cran.org.uk]
Sent: Tuesday, July 07, 2015 18:15
To: Liu, Yingke D; edk2-***@lists.sourceforge.net
Cc: Bruce Cran
Subject: [PATCH] BaseTools: Fix build on FreeBSD and allow use of non-gcc system compiler

On FreeBSD, uuid.h is in /usr/include, not /usr/include/uuid.

Fix some errors when building using clang caused by self-assignment: the preferred way to 'use' a variable is '(void)x;', not 'x = x;'.

Where the system provides $(CC) etc. by default, don't override it to be gcc.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bruce Cran <***@cran.org.uk>
---
BaseTools/Source/C/GenFv/GenFvInternalLib.c | 7 ++++++-
BaseTools/Source/C/LzmaCompress/LzmaCompress.c | 4 ++--
BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 2 +-
BaseTools/Source/C/Makefiles/header.makefile | 10 +++++-----
BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 2 +-
5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index ed9d496..0050985 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -16,8 +16,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Include files
//
-#ifdef __GNUC__
+
+#if defined(__FreeBSD__)
+#include <uuid.h>
+#elif defined(__GNUC__)
#include <uuid/uuid.h>
+#endif
+#ifdef __GNUC__
#include <sys/stat.h>
#endif
#include <string.h>
diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
index b569b4e..1de07a3 100644
--- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
+++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
@@ -43,8 +43,8 @@ const char *kCantWriteMessage = "Can not write output file"; const char *kCantAllocateMessage = "Can not allocate memory"; const char *kDataErrorMessage = "Data error";

-static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } -static void SzFree(void *p, void *address) { p = p; MyFree(address); }
+static void *SzAlloc(void *p, size_t size) { (void)p; return
+MyAlloc(size); } static void SzFree(void *p, void *address) { (void)p;
+MyFree(address); }
static ISzAlloc g_Alloc = { SzAlloc, SzFree };

static Bool mQuietMode = False;
diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
index 7272272..95c3c9f 100644
--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
@@ -2112,7 +2112,7 @@ void LzmaEnc_Finish(CLzmaEncHandle pp)
if (p->mtMode)
MatchFinderMt_ReleaseStream(&p->matchFinderMt);
#else
- pp = pp;
+ (void)pp;
#endif
}

diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index 6a759d9..09d2bff 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -21,11 +21,11 @@ CYGWIN:=$(findstring CYGWIN, $(shell uname -s)) LINUX:=$(findstring Linux, $(shell uname -s)) DARWIN:=$(findstring Darwin, $(shell uname -s))

-CC = gcc
-CXX = g++
-AS = gcc
-AR = ar
-LD = ld
+CC ?= gcc
+CXX ?= g++
+AS ?= gcc
+AR ?= ar
+LD ?= ld
LINKER ?= $(CC)
ifeq ($(ARCH), IA32)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/ diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
index 478a3a1..c49cfd8 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
@@ -164,7 +164,7 @@ PCCTS_H=../h
#
# UNIX (default)
#
-CC=gcc
+CC?=gcc
COPT=-O
ANTLR=${BIN_DIR}/antlr
DLG=${BIN_DIR}/dlg
--
2.4.5
Bruce Cran
2015-07-08 07:07:59 UTC
Permalink
Post by Liu, Yingke D
Thanks for your patch, it was committed at revision 17866.
Could you commit it to the UDK2014.SP1 branch too, please?
--
Bruce
Wu, Hao A
2015-07-08 07:47:07 UTC
Permalink
The patch was committed to UDK2014.SP1 branch @ r17884.

Best Regards,
Hao Wu
Post by Liu, Yingke D
-----Original Message-----
Sent: Wednesday, July 08, 2015 3:08 PM
To: Liu, Yingke D
Subject: Re: [edk2] [PATCH] BaseTools: Fix build on FreeBSD and allow use of
non-gcc system compiler
Post by Liu, Yingke D
Thanks for your patch, it was committed at revision 17866.
Could you commit it to the UDK2014.SP1 branch too, please?
--
Bruce
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Loading...