4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-19 04:49:25 +08:00

Cygwin: Remove ccwrap

ccwrap massages the compiler's standard include directories to remove
'/usr/include/w32api', with the intent of allowing it to be overriden by
'--with-windows-headers' (See 4c36016b).

I'm not 100% convinced that this is always working as desired, since in
some places w32api includes are done using <w32api/something.h>, which
will find them via the path /usr/include.

If this does turn out to be needed, this could also be implemented by
constructing the appropriate compiler flags once, rather than on every
compiler invocation.
This commit is contained in:
Jon Turney 2020-10-03 14:41:58 +01:00
parent 5601d53640
commit b55e3f1916
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
16 changed files with 68 additions and 166 deletions

View File

@ -21,8 +21,8 @@ opt=$(filter -O%,${CFLAGS}) $(filter -g%,${CFLAGS})
override CXXFLAGS:=${filter-out -g%,$(filter-out -O%,${CXXFLAGS})} ${opt}
cflags_common:=-Wall -Wstrict-aliasing -Wwrite-strings -fno-common -pipe -fbuiltin -fmessage-length=0
COMPILE.cc=c++wrap ${CXXFLAGS} -fno-rtti -fno-exceptions -fno-use-cxa-atexit ${cflags_common}
COMPILE.c=ccwrap ${CFLAGS} ${cflags_common}
COMPILE.cc=${CXX} ${INCLUDES} ${CXXFLAGS} -fno-rtti -fno-exceptions -fno-use-cxa-atexit ${cflags_common}
COMPILE.c=${CC} ${INCLUDES} ${CFLAGS} ${cflags_common}
top_srcdir:=$(call justdir,${winsup_srcdir})
top_builddir:=$(call justdir,${target_builddir})

View File

@ -29,7 +29,6 @@ AC_SUBST(windows_libdir)
)
AC_DEFUN([AC_CYGWIN_INCLUDES], [
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -56,13 +55,14 @@ else
AC_MSG_ERROR([cannot find windows header files])
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
AC_SUBST(windows_headers)
AC_SUBST(newlib_headers)
AC_SUBST(cygwin_headers)
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"
AC_SUBST(INCLUDES)
])
AC_DEFUN([AC_CONFIGURE_ARGS], [

View File

@ -1,6 +0,0 @@
#!/usr/bin/perl
use strict;
use File::Basename;
my $pgm = basename($0);
(my $wrapper = $pgm) =~ s/\+\+/c/o;
exec $wrapper, '++', @ARGV;

View File

@ -1,51 +0,0 @@
#!/usr/bin/perl
use Cwd;
use strict;
my $cxx;
my $ccorcxx;
if ($ARGV[0] ne '++') {
$ccorcxx = 'CC';
$cxx = 0;
} else {
shift @ARGV;
$ccorcxx = 'CXX';
$cxx = 1;
}
die "$0: $ccorcxx environment variable does not exist\n" unless exists $ENV{$ccorcxx};
$ENV{'LANG'} = 'C';
my @compiler = split ' ', $ENV{$ccorcxx};
if ("@ARGV" !~ / -nostdinc/o) {
my $fd;
push @compiler, ($cxx ? '-xc++' : '-xc');
if (!open $fd, '-|') {
open STDERR, '>&', \*STDOUT;
exec @compiler, '/dev/null', '-v', '-E', '-o', '/dev/null' or die "*** error execing $compiler[0] - $!\n";
}
$compiler[1] =~ s/xc/nostdinc/o;
push @compiler, '-nostdinc' if $cxx;
push @compiler, '-I' . $_ for split ' ', $ENV{CCWRAP_HEADERS};
push @compiler, '-isystem', $_ for split ' ', $ENV{CCWRAP_SYSTEM_HEADERS};
my $finding_paths = 0;
while (<$fd>) {
if (/^\*\*\*/o) {
print;
} elsif ($_ eq "#include <...> search starts here:\n") {
$finding_paths = 1;
} elsif (!$finding_paths) {
next;
} elsif ($_ eq "End of search list.\n") {
last;
} elsif (!m%w32api%o) {
chomp;
s/^\s+//;
push @compiler, '-isystem', Cwd::abs_path($_);
}
}
push @compiler, '-isystem', $_ for split ' ', $ENV{CCWRAP_DIRAFTER_HEADERS};
close $fd;
}
push @compiler, @ARGV;
print join(' ', '+', @compiler), "\n" if $ENV{CCWRAP_VERBOSE};
exec @compiler or die "$0: $compiler[0] failed to execute\n";

16
winsup/configure vendored
View File

@ -590,9 +590,7 @@ enable_option_checking=no
ac_subst_vars='LTLIBOBJS
LIBOBJS
subdirs
cygwin_headers
newlib_headers
windows_headers
INCLUDES
windows_libdir
CPP
ac_ct_CXX
@ -3407,7 +3405,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -3434,12 +3431,13 @@ else
as_fn_error $? "cannot find windows header files" "$LINENO" 5
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"

View File

@ -1,13 +1,3 @@
addto_CPPFLAGS() {
local f
for f; do
case " $CPPFLAGS " in
*\ $f\ *) ;;
*) CPPFLAGS="$CPPFLAGS $f" ;;
esac
done
}
realdirpath() {
[ -z "$1" ] && return 1
(cd "$1" 2>/dev/null && pwd)

View File

@ -11,22 +11,15 @@ target_builddir:=@target_builddir@
winsup_srcdir:=@winsup_srcdir@
configure_args=@configure_args@
export CC:=@CC@
export CXX:=@CXX@
CFLAGS:=@CFLAGS@
override CXXFLAGS=@CXXFLAGS@
override CXXFLAGS+=-MMD -Wimplicit-fallthrough=5 -Werror -D__OUTSIDE_CYGWIN__ -DSYSCONFDIR="\"$(sysconfdir)\""
INCLUDES:=@INCLUDES@
include ${srcdir}/../Makefile.common
cygwin_build:=${target_builddir}/winsup/cygwin
# environment variables used by ccwrap
export CCWRAP_HEADERS:=$(dir ${srcdir})/cygwin ${cygwin_build}
export CCWRAP_SYSTEM_HEADERS:=@cygwin_headers@ @newlib_headers@
export CCWRAP_DIRAFTER_HEADERS:=@windows_headers@
DESTDIR=
prefix:=${DESTDIR}@prefix@
exec_prefix:=${DESTDIR}@exec_prefix@

View File

@ -43,7 +43,6 @@ AC_SUBST(windows_libdir)
)
AC_DEFUN([AC_CYGWIN_INCLUDES], [
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -70,13 +69,14 @@ else
AC_MSG_ERROR([cannot find windows header files])
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
AC_SUBST(windows_headers)
AC_SUBST(newlib_headers)
AC_SUBST(cygwin_headers)
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"
AC_SUBST(INCLUDES)
])
AC_DEFUN([AC_CONFIGURE_ARGS], [

View File

@ -598,9 +598,7 @@ AS
AR
install_host
all_host
cygwin_headers
newlib_headers
windows_headers
INCLUDES
windows_libdir
CPP
ac_ct_CXX
@ -3409,7 +3407,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -3436,12 +3433,13 @@ else
as_fn_error $? "cannot find windows header files" "$LINENO" 5
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"

View File

@ -14,19 +14,12 @@ target_builddir:=@target_builddir@
winsup_srcdir:=@winsup_srcdir@
configure_args=@configure_args@
export CC:=@CC@
export CXX:=@CXX@
CFLAGS?=@CFLAGS@
CXXFLAGS?=@CXXFLAGS@
INCLUDES?=@INCLUDES@
include ${srcdir}/../Makefile.common
# environment variables used by ccwrap
export CCWRAP_HEADERS:=. ${srcdir}
export CCWRAP_SYSTEM_HEADERS:=@cygwin_headers@ @newlib_headers@
export CCWRAP_DIRAFTER_HEADERS:=@windows_headers@
VPATH+=$(srcdir)/regex $(srcdir)/lib $(srcdir)/libc $(srcdir)/math $(srcdir)/tzcode
target_cpu:=@target_cpu@
@ -788,7 +781,7 @@ src_files := $(foreach dir,$(VPATH),$(find_src_files))
# second, so version.cc is always older than winver.o
version.cc: mkvers.sh include/cygwin/version.h winver.rc $(src_files)
@echo "Making version.cc and winver.o";\
/bin/sh ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) ${CFLAGS} $(addprefix -I,${CCWRAP_SYSTEM_HEADERS} ${CCWRAP_DIRAFTER_HEADERS})
/bin/sh ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) ${CFLAGS} -I${srcdir}/include
$(VERSION_OFILES): version.cc
Makefile: ${srcdir}/Makefile.in
@ -815,7 +808,7 @@ CTAGS:
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q \
--regex-C++='/EXPORT_ALIAS *\([a-zA-Z0-9_]*, *([a-zA-Z0-9_]*)\)/\1/' \
--regex-C++='/__ASMNAME *\("([a-zA-Z0-9_]+)"\)/\1/' \
@newlib_headers@ .
.
deps:=${wildcard *.d}
ifneq (,$(deps))

View File

@ -42,7 +42,6 @@ AC_SUBST(windows_libdir)
)
AC_DEFUN([AC_CYGWIN_INCLUDES], [
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -69,13 +68,14 @@ else
AC_MSG_ERROR([cannot find windows header files])
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
AC_SUBST(windows_headers)
AC_SUBST(newlib_headers)
AC_SUBST(cygwin_headers)
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"
AC_SUBST(INCLUDES)
])
AC_DEFUN([AC_CONFIGURE_ARGS], [

View File

@ -606,9 +606,7 @@ AS
AR
install_host
all_host
cygwin_headers
newlib_headers
windows_headers
INCLUDES
windows_libdir
CPP
ac_ct_CXX
@ -3419,7 +3417,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -3446,12 +3443,13 @@ else
as_fn_error $? "cannot find windows header files" "$LINENO" 5
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"

View File

@ -89,7 +89,7 @@ EOF
close TMP;
my @avoid_headers = qw'-D_XMMINTRIN_H_INCLUDED -D_ADXINTRIN_H_INCLUDED -D_EMMINTRIN_H_INCLUDED -D_X86INTRIN_H_INCLUDED';
my @cmd = (@ARGV, @avoid_headers, '-o', "/tmp/$$-1.cc", '-E', "/tmp/$$.cc");
$ENV{CCWRAP_VERBOSE}=1;
system @cmd;
system 'g++', "$tgt_opt", '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc" and
($? == 127 && system 'c++', "$tgt_opt", '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc") and

View File

@ -11,12 +11,10 @@ target_builddir:=@target_builddir@
winsup_srcdir:=@winsup_srcdir@
configure_args=@configure_args@
export CC:=@CC@
export CXX:=@CXX@
CFLAGS_COMMON=-Wimplicit-fallthrough=4 -Werror
CFLAGS:=@CFLAGS@
CXXFLAGS:=@CXXFLAGS@
INCLUDES:=@INCLUDES@
override CFLAGS+=${CFLAGS_COMMON}
override CXXFLAGS+=-fno-exceptions -fno-rtti ${CFLAGS_COMMON}
@ -24,13 +22,6 @@ include ${srcdir}/../Makefile.common
cygwin_build:=${target_builddir}/winsup/cygwin
cygwin_headers:=@cygwin_headers@
# environment variables used by ccwrap
export CCWRAP_HEADERS:=. ${srcdir} $(call justdir,${cygwin_headers})
export CCWRAP_SYSTEM_HEADERS:=${cygwin_headers} @newlib_headers@
export CCWRAP_DIRAFTER_HEADERS:=@windows_headers@
WINDOWS_LIBDIR:=@windows_libdir@
prefix:=@prefix@

View File

@ -42,7 +42,6 @@ AC_SUBST(windows_libdir)
)
AC_DEFUN([AC_CYGWIN_INCLUDES], [
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -69,13 +68,14 @@ else
AC_MSG_ERROR([cannot find windows header files])
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
AC_SUBST(windows_headers)
AC_SUBST(newlib_headers)
AC_SUBST(cygwin_headers)
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"
AC_SUBST(INCLUDES)
])
AC_DEFUN([AC_CONFIGURE_ARGS], [

View File

@ -593,9 +593,7 @@ MINGW_CXX
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
cygwin_headers
newlib_headers
windows_headers
INCLUDES
ac_ct_CXX
CXXFLAGS
CXX
@ -3111,7 +3109,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
addto_CPPFLAGS -nostdinc
: ${ac_cv_prog_CXX:=$CXX}
: ${ac_cv_prog_CC:=$CC}
@ -3138,12 +3135,13 @@ else
as_fn_error $? "cannot find windows header files" "$LINENO" 5
fi
fi
CC=$ac_cv_prog_CC
CXX=$ac_cv_prog_CXX
export CC
export CXX
INCLUDES="-I${srcdir}/../cygwin -I${target_builddir}/winsup/cygwin"
INCLUDES="${INCLUDES} -isystem ${cygwin_headers}"
for h in ${newlib_headers}; do
INCLUDES="${INCLUDES} -isystem $h"
done
INCLUDES="${INCLUDES} -isystem ${windows_headers}"