1*387f9dfdSAndroid Build Coastguard Worker# Copyright (c) 2017 Facebook, Inc. 2*387f9dfdSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License") 3*387f9dfdSAndroid Build Coastguard Worker 4*387f9dfdSAndroid Build Coastguard Workerif (ENABLE_NO_PIE) 5*387f9dfdSAndroid Build Coastguard Worker 6*387f9dfdSAndroid Build Coastguard Workerif (CMAKE_C_COMPILER_ID MATCHES "Clang") 7*387f9dfdSAndroid Build Coastguard Worker set(COMPILER_NOPIE_FLAG "-nopie") 8*387f9dfdSAndroid Build Coastguard Workerelse() 9*387f9dfdSAndroid Build Coastguard Worker set(_backup_c_flags "${CMAKE_REQUIRED_FLAGS}") 10*387f9dfdSAndroid Build Coastguard Worker set(CMAKE_REQUIRED_FLAGS "-no-pie") 11*387f9dfdSAndroid Build Coastguard Worker CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" 12*387f9dfdSAndroid Build Coastguard Worker HAVE_NO_PIE_FLAG) 13*387f9dfdSAndroid Build Coastguard Worker if (HAVE_NO_PIE_FLAG) 14*387f9dfdSAndroid Build Coastguard Worker set(COMPILER_NOPIE_FLAG "-no-pie") 15*387f9dfdSAndroid Build Coastguard Worker else() 16*387f9dfdSAndroid Build Coastguard Worker set(COMPILER_NOPIE_FLAG "") 17*387f9dfdSAndroid Build Coastguard Worker endif() 18*387f9dfdSAndroid Build Coastguard Worker set(CMAKE_REQUIRED_FLAGS "${_backup_c_flags}") 19*387f9dfdSAndroid Build Coastguard Workerendif() 20*387f9dfdSAndroid Build Coastguard Worker 21*387f9dfdSAndroid Build Coastguard Workerendif(ENABLE_NO_PIE) 22*387f9dfdSAndroid Build Coastguard Worker 23*387f9dfdSAndroid Build Coastguard Worker# check whether reallocarray availability 24*387f9dfdSAndroid Build Coastguard Worker# this is used to satisfy reallocarray usage under src/cc/libbpf/ 25*387f9dfdSAndroid Build Coastguard WorkerCHECK_CXX_SOURCE_COMPILES( 26*387f9dfdSAndroid Build Coastguard Worker" 27*387f9dfdSAndroid Build Coastguard Worker#define _GNU_SOURCE 28*387f9dfdSAndroid Build Coastguard Worker#include <stdlib.h> 29*387f9dfdSAndroid Build Coastguard Worker 30*387f9dfdSAndroid Build Coastguard Workerint main(void) 31*387f9dfdSAndroid Build Coastguard Worker{ 32*387f9dfdSAndroid Build Coastguard Worker return !!reallocarray(NULL, 1, 1); 33*387f9dfdSAndroid Build Coastguard Worker} 34*387f9dfdSAndroid Build Coastguard Worker" HAVE_REALLOCARRAY_SUPPORT) 35