From f1b68fe5b9437bd32bba8230375119a6388963ea Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Mon, 4 Apr 2016 08:50:14 -0700 Subject: [PATCH] Always define static_assert(...) to do nothing Summary:public In order to make infer more resiliant to compilation failure, make static_assert to do nothing. As a bonus, set _FORTIFY_SOURCE inside same file instead of command line Reviewed By: jvillard Differential Revision: D3133446 fb-gh-sync-id: 590f4ad fbshipit-source-id: 590f4ad --- infer/lib/clang_wrappers/clang_wrapper | 8 ++------ infer/lib/clang_wrappers/global_defines.h | 19 +++++++++++++++++++ infer/models/cpp/include/infer_model/common.h | 2 -- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 infer/lib/clang_wrappers/global_defines.h diff --git a/infer/lib/clang_wrappers/clang_wrapper b/infer/lib/clang_wrappers/clang_wrapper index eca5f3517..33a03ae74 100755 --- a/infer/lib/clang_wrappers/clang_wrapper +++ b/infer/lib/clang_wrappers/clang_wrapper @@ -39,11 +39,7 @@ done # compiler can't elevate them to error level. COMMAND+=("-Wno-everything") - -# set _FORTIFY_SOURCE to 0 to prevent it from changing some function prototypes -# https://securityblog.redhat.com/2014/03/26/fortify-and-you/ -# We always do it when building models so we should do same thing -# when building any source code -COMMAND+=("-D_FORTIFY_SOURCE=0") +COMMAND+=("-include") +COMMAND+=(${SCRIPT_DIR}/"global_defines.h") "${COMMAND[@]}" diff --git a/infer/lib/clang_wrappers/global_defines.h b/infer/lib/clang_wrappers/global_defines.h new file mode 100644 index 000000000..0341df8a5 --- /dev/null +++ b/infer/lib/clang_wrappers/global_defines.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2016 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +// set _FORTIFY_SOURCE to 0 to prevent it from changing some function prototypes +// https://securityblog.redhat.com/2014/03/26/fortify-and-you/ +// We always do it when building models so we should do same thing +// when building any source code +#define _FORTIFY_SOURCE 0 + +// Make it harder for compilation to fail. When in the future, infer +// wants to use this information, it can call some builtin instead of +// the default static_assert +#define static_assert(...) diff --git a/infer/models/cpp/include/infer_model/common.h b/infer/models/cpp/include/infer_model/common.h index 0f58bdfaa..b19a9f7e5 100644 --- a/infer/models/cpp/include/infer_model/common.h +++ b/infer/models/cpp/include/infer_model/common.h @@ -13,8 +13,6 @@ #include #include -#define static_assert(...) - namespace infer_model { // code compiled with infer headers is not supposed to be executed struct AbortWhenRun {