[edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard

Ard Biesheuvel posted 7 patches 6 years, 6 months ago
Only 5 patches received!
There is a newer version of this series
[edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard
Posted by Ard Biesheuvel 6 years, 6 months ago
When building OpenSSL for ARM or AARCH64 with recent Clang, the following
error may result:

  In file included from .../CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c:18:
  In file included from .../CryptoPkg/Library/OpensslLib/openssl/crypto/include/internal/x509_int.h:10:
  In file included from .../CryptoPkg/Library/OpensslLib/openssl/include/internal/refcount.h:21:
  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdatomic.h:35:
  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdint.h:61:
  /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
  #include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.

This is caused by the fact that the refcount.h header includes compiler
headers that in turn rely on system headers, which we don't support.

Since the C native atomics are a C11 feature, let's explicitly use the
C99 standard instead to work around this issue.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 BaseTools/Conf/tools_def.template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 26a2cf604f74..7fe6f4406a72 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -2280,8 +2280,8 @@ DEFINE CLANG35_ARM_TARGET        = -target arm-linux-gnueabi
 DEFINE CLANG35_AARCH64_TARGET    = -target aarch64-linux-gnu
 
 DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unknown-warning-option
-DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS) DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES)
-DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANG35_AARCH64_TARGET) -mcmodel=small DEF(CLANG35_WARNING_OVERRIDES)
+DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS) DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES) -std=c99
+DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANG35_AARCH64_TARGET) -mcmodel=small DEF(CLANG35_WARNING_OVERRIDES) -std=c99
 
 ##################
 # CLANG35 ARM definitions
@@ -2430,7 +2430,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS     = DEF(GCC5_X64_DLINK2_FLAGS) -O0
 # CLANG38 ARM definitions
 ##################
 DEFINE CLANG38_ARM_TARGET        = -target arm-linux-gnueabi
-DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS) DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-movt
+DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS) DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-movt -std=c99
 DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET) DEF(GCC_ARM_DLINK_FLAGS)
 
 *_CLANG38_ARM_PP_FLAGS           = DEF(GCC_PP_FLAGS)
@@ -2474,7 +2474,7 @@ RELEASE_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L
 # CLANG38 AARCH64 definitions
 ##################
 DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-linux-gnu
-DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANG38_AARCH64_TARGET) -mcmodel=small DEF(CLANG38_WARNING_OVERRIDES)
+DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANG38_AARCH64_TARGET) -mcmodel=small DEF(CLANG38_WARNING_OVERRIDES) -std=c99
 DEFINE CLANG38_AARCH64_DLINK_FLAGS  = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000
 
 *_CLANG38_AARCH64_PP_FLAGS       = DEF(GCC_PP_FLAGS)
-- 
2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41430): https://edk2.groups.io/g/devel/message/41430
Mute This Topic: https://groups.io/mt/31813772/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard
Posted by Liming Gao 6 years, 6 months ago
Ard:
  Is there any impact with new option? If no behavior change, I am OK for this patch. Reviewed-by: Liming Gao <liming.gao@intel.com> 

Thanks
Liming
>-----Original Message-----
>From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>Sent: Tuesday, May 28, 2019 4:52 AM
>To: devel@edk2.groups.io
>Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
><lersek@redhat.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J
><jian.j.wang@intel.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
>Michael D <michael.d.kinney@intel.com>
>Subject: [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force
>use of C99 standard
>
>When building OpenSSL for ARM or AARCH64 with recent Clang, the following
>error may result:
>
>  In file included
>from .../CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c:18:
>  In file included
>from .../CryptoPkg/Library/OpensslLib/openssl/crypto/include/internal/x509_
>int.h:10:
>  In file included
>from .../CryptoPkg/Library/OpensslLib/openssl/include/internal/refcount.h:2
>1:
>  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdatomic.h:35:
>  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdint.h:61:
>  /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not
>found
>  #include <bits/libc-header-start.h>
>         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>  1 error generated.
>
>This is caused by the fact that the refcount.h header includes compiler
>headers that in turn rely on system headers, which we don't support.
>
>Since the C native atomics are a C11 feature, let's explicitly use the
>C99 standard instead to work around this issue.
>
>Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>---
> BaseTools/Conf/tools_def.template | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/BaseTools/Conf/tools_def.template
>b/BaseTools/Conf/tools_def.template
>index 26a2cf604f74..7fe6f4406a72 100755
>--- a/BaseTools/Conf/tools_def.template
>+++ b/BaseTools/Conf/tools_def.template
>@@ -2280,8 +2280,8 @@ DEFINE CLANG35_ARM_TARGET        = -target arm-
>linux-gnueabi
> DEFINE CLANG35_AARCH64_TARGET    = -target aarch64-linux-gnu
>
> DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -
>Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare
>-Wno-empty-body -Wno-unknown-warning-option
>-DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
>DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES)
>-DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
>DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
>DEF(CLANG35_WARNING_OVERRIDES)
>+DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
>DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES) -
>std=c99
>+DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
>DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
>DEF(CLANG35_WARNING_OVERRIDES) -std=c99
>
> ##################
> # CLANG35 ARM definitions
>@@ -2430,7 +2430,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS     =
>DEF(GCC5_X64_DLINK2_FLAGS) -O0
> # CLANG38 ARM definitions
> ##################
> DEFINE CLANG38_ARM_TARGET        = -target arm-linux-gnueabi
>-DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
>DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
>movt
>+DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
>DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
>movt -std=c99
> DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET)
>DEF(GCC_ARM_DLINK_FLAGS)
>
> *_CLANG38_ARM_PP_FLAGS           = DEF(GCC_PP_FLAGS)
>@@ -2474,7 +2474,7 @@ RELEASE_CLANG38_ARM_DLINK_FLAGS  =
>DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L
> # CLANG38 AARCH64 definitions
> ##################
> DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-linux-gnu
>-DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
>DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
>DEF(CLANG38_WARNING_OVERRIDES)
>+DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
>DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
>DEF(CLANG38_WARNING_OVERRIDES) -std=c99
> DEFINE CLANG38_AARCH64_DLINK_FLAGS  =
>DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z
>common-page-size=0x1000
>
> *_CLANG38_AARCH64_PP_FLAGS       = DEF(GCC_PP_FLAGS)
>--
>2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41433): https://edk2.groups.io/g/devel/message/41433
Mute This Topic: https://groups.io/mt/31813772/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard
Posted by Ard Biesheuvel 6 years, 6 months ago
On Tue, 28 May 2019 at 02:17, Liming Gao <liming.gao@intel.com> wrote:
>
> Ard:
>   Is there any impact with new option? If no behavior change, I am OK for this patch. Reviewed-by: Liming Gao <liming.gao@intel.com>
>

We don't rely on anything provided by the C11 standard, so it should
not result in a behavior change. I do wonder whether x86 may be
affected as well, though.

Jian, did you try building OpenSSL 1.1.1b for x86 with the CLANG38
toolchain with a recent version of Clang?



> >-----Original Message-----
> >From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >Sent: Tuesday, May 28, 2019 4:52 AM
> >To: devel@edk2.groups.io
> >Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> ><lersek@redhat.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J
> ><jian.j.wang@intel.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> >Michael D <michael.d.kinney@intel.com>
> >Subject: [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force
> >use of C99 standard
> >
> >When building OpenSSL for ARM or AARCH64 with recent Clang, the following
> >error may result:
> >
> >  In file included
> >from .../CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c:18:
> >  In file included
> >from .../CryptoPkg/Library/OpensslLib/openssl/crypto/include/internal/x509_
> >int.h:10:
> >  In file included
> >from .../CryptoPkg/Library/OpensslLib/openssl/include/internal/refcount.h:2
> >1:
> >  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdatomic.h:35:
> >  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdint.h:61:
> >  /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not
> >found
> >  #include <bits/libc-header-start.h>
> >         ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >  1 error generated.
> >
> >This is caused by the fact that the refcount.h header includes compiler
> >headers that in turn rely on system headers, which we don't support.
> >
> >Since the C native atomics are a C11 feature, let's explicitly use the
> >C99 standard instead to work around this issue.
> >
> >Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >---
> > BaseTools/Conf/tools_def.template | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> >diff --git a/BaseTools/Conf/tools_def.template
> >b/BaseTools/Conf/tools_def.template
> >index 26a2cf604f74..7fe6f4406a72 100755
> >--- a/BaseTools/Conf/tools_def.template
> >+++ b/BaseTools/Conf/tools_def.template
> >@@ -2280,8 +2280,8 @@ DEFINE CLANG35_ARM_TARGET        = -target arm-
> >linux-gnueabi
> > DEFINE CLANG35_AARCH64_TARGET    = -target aarch64-linux-gnu
> >
> > DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -
> >Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare
> >-Wno-empty-body -Wno-unknown-warning-option
> >-DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> >DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES)
> >-DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> >DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
> >DEF(CLANG35_WARNING_OVERRIDES)
> >+DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> >DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES) -
> >std=c99
> >+DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> >DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
> >DEF(CLANG35_WARNING_OVERRIDES) -std=c99
> >
> > ##################
> > # CLANG35 ARM definitions
> >@@ -2430,7 +2430,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS     =
> >DEF(GCC5_X64_DLINK2_FLAGS) -O0
> > # CLANG38 ARM definitions
> > ##################
> > DEFINE CLANG38_ARM_TARGET        = -target arm-linux-gnueabi
> >-DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> >DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
> >movt
> >+DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> >DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
> >movt -std=c99
> > DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET)
> >DEF(GCC_ARM_DLINK_FLAGS)
> >
> > *_CLANG38_ARM_PP_FLAGS           = DEF(GCC_PP_FLAGS)
> >@@ -2474,7 +2474,7 @@ RELEASE_CLANG38_ARM_DLINK_FLAGS  =
> >DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L
> > # CLANG38 AARCH64 definitions
> > ##################
> > DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-linux-gnu
> >-DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> >DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
> >DEF(CLANG38_WARNING_OVERRIDES)
> >+DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> >DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
> >DEF(CLANG38_WARNING_OVERRIDES) -std=c99
> > DEFINE CLANG38_AARCH64_DLINK_FLAGS  =
> >DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z
> >common-page-size=0x1000
> >
> > *_CLANG38_AARCH64_PP_FLAGS       = DEF(GCC_PP_FLAGS)
> >--
> >2.20.1
>
>
> 
>

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41445): https://edk2.groups.io/g/devel/message/41445
Mute This Topic: https://groups.io/mt/31813772/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard
Posted by Wang, Jian J 6 years, 6 months ago
Ard,

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Tuesday, May 28, 2019 2:11 PM
> To: edk2-devel-groups-io <devel@edk2.groups.io>; Gao, Liming
> <liming.gao@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Leif Lindholm <leif.lindholm@linaro.org>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM
> AARCH64: force use of C99 standard
> 
> On Tue, 28 May 2019 at 02:17, Liming Gao <liming.gao@intel.com> wrote:
> >
> > Ard:
> >   Is there any impact with new option? If no behavior change, I am OK for this
> patch. Reviewed-by: Liming Gao <liming.gao@intel.com>
> >
> 
> We don't rely on anything provided by the C11 standard, so it should
> not result in a behavior change. I do wonder whether x86 may be
> affected as well, though.
> 
> Jian, did you try building OpenSSL 1.1.1b for x86 with the CLANG38
> toolchain with a recent version of Clang?
> 
> 

We just tried but failed. Need to add similar options
for crypto lib. We'll do it in openssl upgrade patch v5.

> 
> > >-----Original Message-----
> > >From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> > >Sent: Tuesday, May 28, 2019 4:52 AM
> > >To: devel@edk2.groups.io
> > >Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > ><lersek@redhat.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J
> > ><jian.j.wang@intel.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> > >Michael D <michael.d.kinney@intel.com>
> > >Subject: [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force
> > >use of C99 standard
> > >
> > >When building OpenSSL for ARM or AARCH64 with recent Clang, the
> following
> > >error may result:
> > >
> > >  In file included
> > >from .../CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c:18:
> > >  In file included
> > >from .../CryptoPkg/Library/OpensslLib/openssl/crypto/include/internal/x509
> _
> > >int.h:10:
> > >  In file included
> > >from .../CryptoPkg/Library/OpensslLib/openssl/include/internal/refcount.h:2
> > >1:
> > >  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdatomic.h:35:
> > >  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdint.h:61:
> > >  /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not
> > >found
> > >  #include <bits/libc-header-start.h>
> > >         ^~~~~~~~~~~~~~~~~~~~~~~~~~
> > >  1 error generated.
> > >
> > >This is caused by the fact that the refcount.h header includes compiler
> > >headers that in turn rely on system headers, which we don't support.
> > >
> > >Since the C native atomics are a C11 feature, let's explicitly use the
> > >C99 standard instead to work around this issue.
> > >
> > >Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > >---
> > > BaseTools/Conf/tools_def.template | 8 ++++----
> > > 1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > >diff --git a/BaseTools/Conf/tools_def.template
> > >b/BaseTools/Conf/tools_def.template
> > >index 26a2cf604f74..7fe6f4406a72 100755
> > >--- a/BaseTools/Conf/tools_def.template
> > >+++ b/BaseTools/Conf/tools_def.template
> > >@@ -2280,8 +2280,8 @@ DEFINE CLANG35_ARM_TARGET        = -target
> arm-
> > >linux-gnueabi
> > > DEFINE CLANG35_AARCH64_TARGET    = -target aarch64-linux-gnu
> > >
> > > DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -
> > >Wno-tautological-compare -Wno-tautological-constant-out-of-range-
> compare
> > >-Wno-empty-body -Wno-unknown-warning-option
> > >-DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES)
> > >-DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG35_WARNING_OVERRIDES)
> > >+DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES) -
> > >std=c99
> > >+DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG35_WARNING_OVERRIDES) -std=c99
> > >
> > > ##################
> > > # CLANG35 ARM definitions
> > >@@ -2430,7 +2430,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS     =
> > >DEF(GCC5_X64_DLINK2_FLAGS) -O0
> > > # CLANG38 ARM definitions
> > > ##################
> > > DEFINE CLANG38_ARM_TARGET        = -target arm-linux-gnueabi
> > >-DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
> > >movt
> > >+DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
> > >movt -std=c99
> > > DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET)
> > >DEF(GCC_ARM_DLINK_FLAGS)
> > >
> > > *_CLANG38_ARM_PP_FLAGS           = DEF(GCC_PP_FLAGS)
> > >@@ -2474,7 +2474,7 @@ RELEASE_CLANG38_ARM_DLINK_FLAGS  =
> > >DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L
> > > # CLANG38 AARCH64 definitions
> > > ##################
> > > DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-linux-gnu
> > >-DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG38_WARNING_OVERRIDES)
> > >+DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG38_WARNING_OVERRIDES) -std=c99
> > > DEFINE CLANG38_AARCH64_DLINK_FLAGS  =
> > >DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z
> > >common-page-size=0x1000
> > >
> > > *_CLANG38_AARCH64_PP_FLAGS       = DEF(GCC_PP_FLAGS)
> > >--
> > >2.20.1
> >
> >
> > 
> >

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41457): https://edk2.groups.io/g/devel/message/41457
Mute This Topic: https://groups.io/mt/31813772/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard
Posted by Leif Lindholm 6 years, 6 months ago
On Tue, May 28, 2019 at 08:10:44AM +0200, Ard Biesheuvel wrote:
> On Tue, 28 May 2019 at 02:17, Liming Gao <liming.gao@intel.com> wrote:
> >
> > Ard:
> >   Is there any impact with new option? If no behavior change, I am OK for this patch. Reviewed-by: Liming Gao <liming.gao@intel.com>
> >
> 
> We don't rely on anything provided by the C11 standard, so it should
> not result in a behavior change. I do wonder whether x86 may be
> affected as well, though.

A minor concern would be that GCC defaults to "gnu11" since (after a
cursory search) 5.1, so we could be setting ourselves up for future
clashes. Which is possibly fine, as long as we're aware.

/
    Leif

> Jian, did you try building OpenSSL 1.1.1b for x86 with the CLANG38
> toolchain with a recent version of Clang?
> 
> 
> 
> > >-----Original Message-----
> > >From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> > >Sent: Tuesday, May 28, 2019 4:52 AM
> > >To: devel@edk2.groups.io
> > >Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > ><lersek@redhat.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J
> > ><jian.j.wang@intel.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> > >Michael D <michael.d.kinney@intel.com>
> > >Subject: [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force
> > >use of C99 standard
> > >
> > >When building OpenSSL for ARM or AARCH64 with recent Clang, the following
> > >error may result:
> > >
> > >  In file included
> > >from .../CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c:18:
> > >  In file included
> > >from .../CryptoPkg/Library/OpensslLib/openssl/crypto/include/internal/x509_
> > >int.h:10:
> > >  In file included
> > >from .../CryptoPkg/Library/OpensslLib/openssl/include/internal/refcount.h:2
> > >1:
> > >  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdatomic.h:35:
> > >  In file included from /usr/lib/llvm-7/lib/clang/7.0.1/include/stdint.h:61:
> > >  /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not
> > >found
> > >  #include <bits/libc-header-start.h>
> > >         ^~~~~~~~~~~~~~~~~~~~~~~~~~
> > >  1 error generated.
> > >
> > >This is caused by the fact that the refcount.h header includes compiler
> > >headers that in turn rely on system headers, which we don't support.
> > >
> > >Since the C native atomics are a C11 feature, let's explicitly use the
> > >C99 standard instead to work around this issue.
> > >
> > >Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > >---
> > > BaseTools/Conf/tools_def.template | 8 ++++----
> > > 1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > >diff --git a/BaseTools/Conf/tools_def.template
> > >b/BaseTools/Conf/tools_def.template
> > >index 26a2cf604f74..7fe6f4406a72 100755
> > >--- a/BaseTools/Conf/tools_def.template
> > >+++ b/BaseTools/Conf/tools_def.template
> > >@@ -2280,8 +2280,8 @@ DEFINE CLANG35_ARM_TARGET        = -target arm-
> > >linux-gnueabi
> > > DEFINE CLANG35_AARCH64_TARGET    = -target aarch64-linux-gnu
> > >
> > > DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality -
> > >Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare
> > >-Wno-empty-body -Wno-unknown-warning-option
> > >-DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES)
> > >-DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG35_WARNING_OVERRIDES)
> > >+DEFINE CLANG35_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG35_ARM_TARGET) DEF(CLANG35_WARNING_OVERRIDES) -
> > >std=c99
> > >+DEFINE CLANG35_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG35_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG35_WARNING_OVERRIDES) -std=c99
> > >
> > > ##################
> > > # CLANG35 ARM definitions
> > >@@ -2430,7 +2430,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS     =
> > >DEF(GCC5_X64_DLINK2_FLAGS) -O0
> > > # CLANG38 ARM definitions
> > > ##################
> > > DEFINE CLANG38_ARM_TARGET        = -target arm-linux-gnueabi
> > >-DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
> > >movt
> > >+DEFINE CLANG38_ARM_CC_FLAGS      = DEF(GCC_ARM_CC_FLAGS)
> > >DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-
> > >movt -std=c99
> > > DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET)
> > >DEF(GCC_ARM_DLINK_FLAGS)
> > >
> > > *_CLANG38_ARM_PP_FLAGS           = DEF(GCC_PP_FLAGS)
> > >@@ -2474,7 +2474,7 @@ RELEASE_CLANG38_ARM_DLINK_FLAGS  =
> > >DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L
> > > # CLANG38 AARCH64 definitions
> > > ##################
> > > DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-linux-gnu
> > >-DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG38_WARNING_OVERRIDES)
> > >+DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS)
> > >DEF(CLANG38_AARCH64_TARGET) -mcmodel=small
> > >DEF(CLANG38_WARNING_OVERRIDES) -std=c99
> > > DEFINE CLANG38_AARCH64_DLINK_FLAGS  =
> > >DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z
> > >common-page-size=0x1000
> > >
> > > *_CLANG38_AARCH64_PP_FLAGS       = DEF(GCC_PP_FLAGS)
> > >--
> > >2.20.1
> >
> >
> > 
> >

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41466): https://edk2.groups.io/g/devel/message/41466
Mute This Topic: https://groups.io/mt/31813772/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-