From patchwork Thu Oct 26 23:40:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 738341 Delivered-To: patch@linaro.org Received: by 2002:a5d:5101:0:b0:32d:baff:b0ca with SMTP id s1csp148675wrt; Thu, 26 Oct 2023 16:40:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5r6wje5lp5UHC7gBppLW8C/YwWlt1AFGlDsmjUYlhIQT3mGhe++b4pK2V0qeJfAR001D1 X-Received: by 2002:a05:622a:4d3:b0:410:9b45:d7f3 with SMTP id q19-20020a05622a04d300b004109b45d7f3mr1001921qtx.36.1698363630534; Thu, 26 Oct 2023 16:40:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698363630; cv=pass; d=google.com; s=arc-20160816; b=0F4pwoqnCsj7Ppw4ZMfc8peYwhVNIFT//csgpx6B6TrWZECuEI67ktcYVL7xszklck CJ2W2/3imlqN/lJWMu3uTUUz46TmXOVIM6wPiDC2ByKv5aAZ2/mqg0CtyQu3z92b2Aqh Y7ZlZB6Rnu65yUI9UCg2WR0f1s6/T8OM/WEj5SYzKqu0C19IDqsSxyyZMNpSTWRXBxfa USiflFOn5T91X8pwsNp5px5CCtIczhrUDJ2mcUvDvv8cxTI+NeMTkZOgsEKAYFXPfYiB ipHJemj2AIxWOiaO9cyqFgR07g0X6Ag33gkMXJCPN3VP4A3AaUZol8HoUPq5v+6SbvmJ EicA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=9YrtomdVVaY9eCIBnNLXeVMcfUShrDKnGcrRDh3MP5c=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=RIUJusyYFyJyuYv3B6BrEtUw7jCByFCC57gbcAQw9kOSjDoXPKQ2jfsACmberqDiU5 Ro5kB49q59fLqf9Na7wiZqNTHfzrInupxgQ/EyJJWO/fXfocmy/uy7kav28cM41ZQ9d0 04fHsjfrwwOFLWJ1JRzQKladvH9pohbCTk7JH9qmWlhc5Tua4GFbKbc14pV8GkRI/Bh9 +dg5ySMzmS/skTJLcBVXz9UbRYbCDdDgF8J5XYSqkI21iIWWtNkkcbS2PRWRYaqDPlek F5zjBQjSUNEDdHej/ioG7wDagDNg1iFPIvW6ZFZT926BG1YWvRj65VaqfqC3DXZLOjM6 1p7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O3Sal8it; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i17-20020ac85e51000000b00419783cf7ebsi213673qtx.532.2023.10.26.16.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 16:40:30 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O3Sal8it; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32B263858298 for ; Thu, 26 Oct 2023 23:40:30 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 5E6C43858D32 for ; Thu, 26 Oct 2023 23:40:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E6C43858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5E6C43858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698363619; cv=none; b=A51wVx8/5OqDyrEA145xQggsR6RFwmvu7udI1TlDEbgriFGRKuYX+UVXS6rKqYm0pMtxHXM5mogU/i7akbfFLRcoNQ7eYJR/4ZTt08WSPql4yi5nLwK9GEY8NCSPJNhgafqyi9Y+zy7G0aTc24mCyR4v/s6zKIJlja8xEa/M2ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698363619; c=relaxed/simple; bh=BgVaR86B7eWKfn+sGs4Gg6ojR0OruJhQibJjq0+Ou4M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k8/DgQiJZubqMwanx1uMtkl41eIJlWKI0exFKcBfvMgCetI+gEexe/LBXMigNN86CxjpK/yg7OdAZfIJ1mT8sCLlA7fKaOEMNpIfuuN0nEOGadjF4ophfxKFZ0Hnweo8ffjT8wnag1JNLF93MRkGnjKsMaht6DUAmyT8sfBnZUo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c9b7c234a7so12942725ad.3 for ; Thu, 26 Oct 2023 16:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698363616; x=1698968416; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9YrtomdVVaY9eCIBnNLXeVMcfUShrDKnGcrRDh3MP5c=; b=O3Sal8itvRsFZqlsmsz/yLvOKULfUgXioz+oHmViPPEXUAap2r7OEdc2eu6T5avODw CB8Qdfe5pqFdOK5MIUMxsD8MW+fFcDYdjZBPrWSgJwJhsorx3P7RCSAx3IhG8ZL0/2Cz FdyriVqoc5F5l8vWc8iAyRO7GkT+rfpnH0+nMVXuFejXSw6yp6YNQhi+5SL7lYaheQ3e 86+GUXitzDUdjm3wc80jfQM/AUgaCxgFdNhKSat0Bz85VCMb0D8u51s8DYMH/tZJidyk B3N/vbfr3tPZtr1JQtWg5WpCpf5qy4qILz4iQoDd1KaYP7NYikvXifPHX1lSN6HTNWwb qF4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698363616; x=1698968416; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9YrtomdVVaY9eCIBnNLXeVMcfUShrDKnGcrRDh3MP5c=; b=LbhrkxBa30u6/lFq/JJjXCgJj6bGoldVEzjwfZ3zaQJtlyOm/PzIyfkeEy1Z3s208o PvXg2oS7F2iD1guY0vfR22v3jO/+j52fPWs5qtURjzW7Zwt5ZrNagzB8Mw0dQ+Bf5Ip/ Ov91QrAZAuYXRB8Bykr3WQsFL2efbDjrtjZD6m6Si7irb3FpavPDaMT3fqDFmx1VXBvE kZDgfM2A+F3gp0fr9eFK82dYGrULQBKtzsP4e7UmXWyiQdrfvdH2xVpC+REXGbUfTwyd hkxRQ+2v7wzmWq7pADMWHfukxiNi6vFDCTHfG6W9vMRglG5BUB18G7WK1WBsYOrw8oP5 oQHw== X-Gm-Message-State: AOJu0YwTxqyr8FeQ6rtQdncJlRuOYaoO4JUmpt6oRGHybllU2pSVW3pg 3vEo1nFCnipZkbCKKyffTIZA0TLx0LcB/3lEXBo= X-Received: by 2002:a17:902:f213:b0:1c3:4b24:d89d with SMTP id m19-20020a170902f21300b001c34b24d89dmr941248plc.40.1698363616095; Thu, 26 Oct 2023 16:40:16 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:bc3a:99e3:6ac:f545]) by smtp.gmail.com with ESMTPSA id r21-20020a170902be1500b001cbf3824360sm236365pls.95.2023.10.26.16.40.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 16:40:15 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH] gdb/configure.ac: Fix auto-load options to work with Windows path separator Date: Thu, 26 Oct 2023 20:40:13 -0300 Message-ID: <20231026234013.937210-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org Both --with-auto-load-dir and --with-auto-load-safe-path accept a list of directories, which are separated by ':' on Unix and ';' on Windows. However, as mentioned in PR 18898 this doesn't work on the latter OS. This is because the AC_DEFINE_DIR macro calls eval twice on the value provided via these configure options, causing the ';' to be interpreted by the shell. E.g., $ ~/src/binutils-gdb/configure \ --disable-{binutils,ld,gold,gas,sim,gprof,gprofng} \ --with-auto-load-dir='foo;bar' && make ⋮ checking for default auto-load directory... /home/bauermann/src/binutils-gdb/gdb/configure: line 18004: bar: command not found foo;bar checking for default auto-load safe-path... /home/bauermann/src/binutils-gdb/gdb/configure: line 18031: bar: command not found foo;bar Line 18004 is: ac_define_dir=`eval echo $escape_dir` Line 18031 is identical. With some escaping, it's possible to avoid the problem: $ ~/src/binutils-gdb/configure \ --disable-{binutils,ld,gold,gas,sim,gprof,gprofng} \ --with-auto-load-dir='foo\\\;bar\\\;baz' && make ⋮ checking for default auto-load directory... foo\\\;bar\\\;baz checking for default auto-load safe-path... foo\\\;bar\\\;baz ⋮ $ grep AUTO_LOAD gdb/config.h #define AUTO_LOAD_DIR "foo;bar;baz" #define AUTO_LOAD_SAFE_PATH "foo;bar;baz" We provide the definition of AC_DEFINE_DIR in gdb/acinclude.m4 so the simplest approach to fix this problem would be to remove the evals from the macro. I don't know why they are there however, so instead I decided to make gdb/configure.ac automatically add those escaping characters to the values of the options if the host OS is Windows. I don't know if Cygwin also needs this change, so for now I'm only adding it for MinGW. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18898 --- Hello, This addresses the problem that Eli has been having with these options on MinGW. I don't have access to a Windows system, so I tested the patch on Linux by changing the case to match "linux*" rather than "mingw*" and using the build and grep commands mentioned in the commit message. It would be nice if someone could test on an actual Windows system, and also let me know if other host_os strings should also be matched (e.g., "cygwin*" or "windows*") gdb/configure | 20 ++++++++++++++++++-- gdb/configure.ac | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/gdb/configure b/gdb/configure index 5361bf42952a..96f0e3da9637 100755 --- a/gdb/configure +++ b/gdb/configure @@ -17997,7 +17997,15 @@ else with_auto_load_dir='$debugdir:$datadir/auto-load' fi -escape_dir=`echo $with_auto_load_dir | sed -e 's/[$]datadir\>/\\\\\\\\\\\\&/g' -e 's/[$]debugdir\>/\\\\\\\\\\\\&/g'` +# If we're on Windows, we need to protect the PATH separator ';' from the couple +# of eval calls done by AC_DEFINE_DIR. +extra_sed_args=() +case "$host_os" in + mingw*) + extra_sed_args=(-e 's/;/\\\\\\;/g') + ;; +esac +escape_dir=`echo $with_auto_load_dir | sed -e 's/[$]datadir\>/\\\\\\\\\\\\&/g' -e 's/[$]debugdir\>/\\\\\\\\\\\\&/g' "${extra_sed_args[@]}"` test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' @@ -18024,7 +18032,15 @@ else with_auto_load_safe_path="$with_auto_load_dir" fi -escape_dir=`echo $with_auto_load_safe_path | sed -e 's/[$]datadir\>/\\\\\\\\\\\\&/g' -e 's/[$]debugdir\>/\\\\\\\\\\\\&/g'` +# If we're on Windows, we need to protect the PATH separator ';' from the couple +# of eval calls done by AC_DEFINE_DIR. +extra_sed_args=() +case "$host_os" in + mingw*) + extra_sed_args=(-e 's/;/\\\\\\;/g') + ;; +esac +escape_dir=`echo $with_auto_load_safe_path | sed -e 's/[$]datadir\>/\\\\\\\\\\\\&/g' -e 's/[$]debugdir\>/\\\\\\\\\\\\&/g' "${extra_sed_args[@]}"` test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' diff --git a/gdb/configure.ac b/gdb/configure.ac index 3912b77b27f2..cc8d2bfc5e8b 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -153,7 +153,15 @@ AC_ARG_WITH(auto-load-dir, AS_HELP_STRING([--with-auto-load-dir=PATH], [directories from which to load auto-loaded scripts @<:@$debugdir:$datadir/auto-load@:>@]),, [with_auto_load_dir='$debugdir:$datadir/auto-load']) -escape_dir=`echo $with_auto_load_dir | sed -e 's/[[$]]datadir\>/\\\\\\\\\\\\&/g' -e 's/[[$]]debugdir\>/\\\\\\\\\\\\&/g'` +# If we're on Windows, we need to protect the PATH separator ';' from the couple +# of eval calls done by AC_DEFINE_DIR. +extra_sed_args=() +case "$host_os" in + mingw*) + extra_sed_args=(-e 's/;/\\\\\\;/g') + ;; +esac +escape_dir=`echo $with_auto_load_dir | sed -e 's/[[$]]datadir\>/\\\\\\\\\\\\&/g' -e 's/[[$]]debugdir\>/\\\\\\\\\\\\&/g' "${extra_sed_args[[@]]}"` AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir, [Directories from which to load auto-loaded scripts.]) AC_MSG_RESULT([$with_auto_load_dir]) @@ -168,7 +176,15 @@ AS_HELP_STRING([--without-auto-load-safe-path], with_auto_load_safe_path="/" fi], [with_auto_load_safe_path="$with_auto_load_dir"]) -escape_dir=`echo $with_auto_load_safe_path | sed -e 's/[[$]]datadir\>/\\\\\\\\\\\\&/g' -e 's/[[$]]debugdir\>/\\\\\\\\\\\\&/g'` +# If we're on Windows, we need to protect the PATH separator ';' from the couple +# of eval calls done by AC_DEFINE_DIR. +extra_sed_args=() +case "$host_os" in + mingw*) + extra_sed_args=(-e 's/;/\\\\\\;/g') + ;; +esac +escape_dir=`echo $with_auto_load_safe_path | sed -e 's/[[$]]datadir\>/\\\\\\\\\\\\&/g' -e 's/[[$]]debugdir\>/\\\\\\\\\\\\&/g' "${extra_sed_args[[@]]}"` AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, [Directories safe to hold auto-loaded files.]) AC_MSG_RESULT([$with_auto_load_safe_path])