From 8bfc9a18c670316534d85ec977742ecb2d598474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 8 Oct 2018 11:44:04 +0300 Subject: [PATCH] Error out early if trying to compile ada If we try to do that, clang would end up calling -gcc with the same arguments. In our setup, this recursively ends up calling clang again, ending up with infinite recursion. --- wrappers/clang-target-wrapper.c | 10 ++++++++++ wrappers/clang-target-wrapper.sh | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/wrappers/clang-target-wrapper.c b/wrappers/clang-target-wrapper.c index f0fca61..976d642 100644 --- a/wrappers/clang-target-wrapper.c +++ b/wrappers/clang-target-wrapper.c @@ -142,6 +142,16 @@ int _tmain(int argc, TCHAR* argv[]) { if (dash) *dash = '\0'; + // Check if trying to compile Ada; if we try to do this, invoking clang + // would end up invoking -gcc with the same arguments, which ends + // up in an infinite recursion. + for (int i = 1; i < argc - 1; i++) { + if (!_tcscmp(argv[i], _T("-x")) && !_tcscmp(argv[i + 1], _T("ada"))) { + fprintf(stderr, "Ada is not supported\n"); + return 1; + } + } + int max_arg = argc + 20; const TCHAR **exec_argv = malloc(max_arg * sizeof(*exec_argv)); int arg = 0; diff --git a/wrappers/clang-target-wrapper.sh b/wrappers/clang-target-wrapper.sh index 296da77..50badb2 100755 --- a/wrappers/clang-target-wrapper.sh +++ b/wrappers/clang-target-wrapper.sh @@ -9,6 +9,18 @@ if [ "$TARGET" = "$BASENAME" ]; then fi ARCH="${TARGET%%-*}" +# Check if trying to compile Ada; if we try to do this, invoking clang +# would end up invoking -gcc with the same arguments, which ends +# up in an infinite recursion. +case "$*" in +*-x\ ada*) + echo "Ada is not supported" >&2 + exit 1 + ;; +*) + ;; +esac + # Allow setting e.g. CCACHE=1 to wrap all building in ccache. if [ -n "$CCACHE" ]; then CCACHE=ccache