Commit 6009a54a authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[Reland] Stop using -std=gnu*

This reland includes a patch that fixes the AFL build with CFLAGS="-std=c11
-D_GNU_SOURCE".

BUG=427584
TBR=thakis,sbc

Change-Id: I9c3c52f4898a9ae1efc377802671ac44b79e9381
Reviewed-on: https://chromium-review.googlesource.com/1180170
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarJonathan Metzman <metzman@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584284}
parent 23eec822
...@@ -550,16 +550,22 @@ config("compiler") { ...@@ -550,16 +550,22 @@ config("compiler") {
cxx11_override = use_cxx11 cxx11_override = use_cxx11
} }
# gnu11/gnu++11 instead of c11/c++11 is needed because some code uses typeof() # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
# (a GNU extension). # defined by the compiler. However, lots of code relies on the non-standard
# TODO(thakis): Eventually switch this to c++11 instead, # features that _GNU_SOURCE enables, so define it manually.
# http://crbug.com/427584 defines += [ "_GNU_SOURCE" ]
cflags_c += [ "-std=gnu11" ]
cflags_c += [ "-std=c11" ]
if (cxx11_override) { if (cxx11_override) {
# Override Chromium's default for projects that wish to stay on C++11. # Override Chromium's default for projects that wish to stay on C++11.
cflags_cc += [ "-std=gnu++11" ] cflags_cc += [ "-std=c++11" ]
} else { } else {
cflags_cc += [ "-std=gnu++14" ] cflags_cc += [ "-std=c++14" ]
}
if (is_nacl) {
# Undefine __STRICT_ANSI__ to get non-standard features which would
# otherwise not be enabled by NaCl's sysroots.
cflags += [ "-U__STRICT_ANSI__" ]
} }
} else if (!is_win && !is_nacl) { } else if (!is_win && !is_nacl) {
if (target_os == "android") { if (target_os == "android") {
......
...@@ -82,7 +82,7 @@ EXTERN_C_BEGIN ...@@ -82,7 +82,7 @@ EXTERN_C_BEGIN
#define WRAP(name) __nacl_irt_##name##_wrap #define WRAP(name) __nacl_irt_##name##_wrap
// Declare REAL function pointer. // Declare REAL function pointer.
#define DECLARE_REAL_PTR(name) typeof(__nacl_irt_##name) REAL(name); #define DECLARE_REAL_PTR(name) __typeof__(__nacl_irt_##name) REAL(name);
// Assign the REAL function pointer. // Assign the REAL function pointer.
#define ASSIGN_REAL_PTR(name) \ #define ASSIGN_REAL_PTR(name) \
...@@ -90,10 +90,12 @@ EXTERN_C_BEGIN ...@@ -90,10 +90,12 @@ EXTERN_C_BEGIN
REAL(name) = __nacl_irt_##name; REAL(name) = __nacl_irt_##name;
// Switch IRT's pointer to the REAL pointer // Switch IRT's pointer to the REAL pointer
#define USE_REAL(name) __nacl_irt_##name = (typeof(__nacl_irt_##name))REAL(name) #define USE_REAL(name) \
__nacl_irt_##name = (__typeof__(__nacl_irt_##name))REAL(name)
// Switch IRT's pointer to the WRAP function // Switch IRT's pointer to the WRAP function
#define USE_WRAP(name) __nacl_irt_##name = (typeof(__nacl_irt_##name))WRAP(name) #define USE_WRAP(name) \
__nacl_irt_##name = (__typeof__(__nacl_irt_##name))WRAP(name)
#define EXPAND_SYMBOL_LIST_OPERATION(OP) \ #define EXPAND_SYMBOL_LIST_OPERATION(OP) \
OP(chdir); \ OP(chdir); \
......
...@@ -32,18 +32,18 @@ EXTERN_C_BEGIN ...@@ -32,18 +32,18 @@ EXTERN_C_BEGIN
// Declare REAL function pointer. // Declare REAL function pointer.
#define DECLARE_REAL_PTR(group, name) \ #define DECLARE_REAL_PTR(group, name) \
typeof(__libnacl_irt_##group.name) REAL(name); __typeof__(__libnacl_irt_##group.name) REAL(name);
// Assign the REAL function pointer. // Assign the REAL function pointer.
#define ASSIGN_REAL_PTR(group, name) REAL(name) = __libnacl_irt_##group.name; #define ASSIGN_REAL_PTR(group, name) REAL(name) = __libnacl_irt_##group.name;
// Switch IRT's pointer to the REAL pointer // Switch IRT's pointer to the REAL pointer
#define USE_REAL(group, name) \ #define USE_REAL(group, name) \
__libnacl_irt_##group.name = (typeof(REAL(name)))REAL(name); __libnacl_irt_##group.name = (__typeof__(REAL(name)))REAL(name);
// Switch the IRT's pointer to the WRAP function // Switch the IRT's pointer to the WRAP function
#define USE_WRAP(group, name) \ #define USE_WRAP(group, name) \
__libnacl_irt_##group.name = (typeof(REAL(name)))WRAP(name); __libnacl_irt_##group.name = (__typeof__(REAL(name)))WRAP(name);
extern void __libnacl_irt_dev_filename_init(void); extern void __libnacl_irt_dev_filename_init(void);
extern void __libnacl_irt_dev_fdio_init(void); extern void __libnacl_irt_dev_fdio_init(void);
......
...@@ -2,7 +2,7 @@ Name: American Fuzzy Lop ...@@ -2,7 +2,7 @@ Name: American Fuzzy Lop
Short Name: AFL Short Name: AFL
URL: http://lcamtuf.coredump.cx/afl/ URL: http://lcamtuf.coredump.cx/afl/
Version: 2.52b Version: 2.52b
Date: December 13, 2017 Date: August 17, 2018
License: Apache 2.0 License: Apache 2.0
License File: src/docs/COPYING License File: src/docs/COPYING
Security Critical: no Security Critical: no
...@@ -20,3 +20,5 @@ Local Modifications: ...@@ -20,3 +20,5 @@ Local Modifications:
- src/testcases/others/elf - src/testcases/others/elf
- src/llvm_mode/afl-llvm-pass.so.cc - src/llvm_mode/afl-llvm-pass.so.cc
- src/dictionaries/ - src/dictionaries/
- patches/0001-fix-build-with-std-c11.patch
- Fix build with CFLAGS="-std=c11 -D_GNU_SOURCE"
diff --git a/afl-fuzz.c b/afl-fuzz.c
index 01b4afef0ecc..f0d564a33037 100644
--- a/afl-fuzz.c
+++ b/afl-fuzz.c
@@ -23,7 +23,9 @@
#define AFL_MAIN
#define MESSAGES_TO_STDOUT
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#define _FILE_OFFSET_BITS 64
#include "config.h"
diff --git a/types.h b/types.h
index 784d3a7a286d..d24d1fdd97e8 100644
--- a/types.h
+++ b/types.h
@@ -78,7 +78,7 @@ typedef int64_t s64;
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
#define MEM_BARRIER() \
- asm volatile("" ::: "memory")
+ __asm__ volatile("" ::: "memory")
#define likely(_x) __builtin_expect(!!(_x), 1)
#define unlikely(_x) __builtin_expect(!!(_x), 0)
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
#define AFL_MAIN #define AFL_MAIN
#define MESSAGES_TO_STDOUT #define MESSAGES_TO_STDOUT
#ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#include "config.h" #include "config.h"
......
...@@ -78,7 +78,7 @@ typedef int64_t s64; ...@@ -78,7 +78,7 @@ typedef int64_t s64;
#define STRINGIFY(x) STRINGIFY_INTERNAL(x) #define STRINGIFY(x) STRINGIFY_INTERNAL(x)
#define MEM_BARRIER() \ #define MEM_BARRIER() \
asm volatile("" ::: "memory") __asm__ volatile("" ::: "memory")
#define likely(_x) __builtin_expect(!!(_x), 1) #define likely(_x) __builtin_expect(!!(_x), 1)
#define unlikely(_x) __builtin_expect(!!(_x), 0) #define unlikely(_x) __builtin_expect(!!(_x), 0)
......
...@@ -11,6 +11,7 @@ import cStringIO ...@@ -11,6 +11,7 @@ import cStringIO
import datetime import datetime
import os import os
import re import re
import subprocess
import sys import sys
import tarfile import tarfile
import urllib2 import urllib2
...@@ -127,6 +128,16 @@ def version_to_float(version): ...@@ -127,6 +128,16 @@ def version_to_float(version):
return float(version) return float(version)
def apply_patches():
afl_dir = os.path.join('third_party', 'afl')
patch_dir = os.path.join(afl_dir, 'patches')
src_dir = os.path.join(afl_dir, 'src')
for patch_file in os.listdir(patch_dir):
subprocess.check_output(
['patch', '-i',
os.path.join('..', 'patches', patch_file)], cwd=src_dir)
def update_afl(new_version): def update_afl(new_version):
""" """
Update this version of AFL to newer version, new_version. Update this version of AFL to newer version, new_version.
...@@ -142,14 +153,10 @@ def update_afl(new_version): ...@@ -142,14 +153,10 @@ def update_afl(new_version):
# Extract the tarball. # Extract the tarball.
tarball = AflTarball(new_version) tarball = AflTarball(new_version)
tarball.download() tarball.download()
current_less_than_new = version_to_float(old_version) < version_to_float(
tarball.real_version)
assert current_less_than_new, (
'Trying to update from version {0} to {1}'.format(old_version,
tarball.real_version))
tarball.extract() tarball.extract()
apply_patches()
readme.update(tarball.real_version) readme.update(tarball.real_version)
......
...@@ -15,8 +15,10 @@ declare_args() { ...@@ -15,8 +15,10 @@ declare_args() {
if (!use_system_libdrm) { if (!use_system_libdrm) {
config("libdrm_config") { config("libdrm_config") {
# Define _GNU_SOURCE for vasprintf use in xf86drm.c # TODO(thomasanderson): Remove this hack once
defines = [ "_GNU_SOURCE" ] # https://patchwork.kernel.org/patch/10545295/ lands.
defines = [ "typeof(x)=__typeof__(x)" ]
include_dirs = [ include_dirs = [
"src", "src",
"src/include", "src/include",
......
...@@ -16,6 +16,10 @@ if (!use_system_libwayland) { ...@@ -16,6 +16,10 @@ if (!use_system_libwayland) {
"include/protocol", "include/protocol",
"src/src", "src/src",
] ]
# TODO(thomasanderson): Remove this once
# https://patchwork.freedesktop.org/patch/242086/ lands.
cflags = [ "-Wno-macro-redefined" ]
} }
static_library("wayland_util") { static_library("wayland_util") {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment