From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45976 invoked by alias); 4 May 2018 16:55:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 45963 invoked by uid 89); 4 May 2018 16:55:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=bomb, Until, our X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 May 2018 16:55:56 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 49497117C0F; Fri, 4 May 2018 12:55:54 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Z5g7sOHLiu+f; Fri, 4 May 2018 12:55:54 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 18B4A117C07; Fri, 4 May 2018 12:55:54 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 5C42583055; Fri, 4 May 2018 09:55:52 -0700 (PDT) Date: Fri, 04 May 2018 16:55:00 -0000 From: Joel Brobecker To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Define GNULIB_NAMESPACE in unittests/string_view-selftests.c Message-ID: <20180504165552.f4y7zcxzmgvwngel@adacore.com> References: <1525382648-30186-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525382648-30186-1-git-send-email-simon.marchi@ericsson.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SW-Source: 2018-05/txt/msg00098.txt.bz2 > When building with x86_64-w64-mingw32-g++ (to test cross-compiling for > Windows), I get this error: > > unittests/string_view-selftests.o: In function `selftests::string_view::inserters_2::test05(unsigned long long)': > /home/emaisin/src/binutils-gdb/gdb/unittests/basic_string_view/inserters/char/2.cc:60: undefined reference to `std::basic_ofstream >::rpl_close()' > > This is caused by gnulib redefining "close" as "rpl_close", and > therefore messing up the declaration of basic_ofstream in the libstdc++ > header. The solution would be to use gnulib namespaces [1]. Until we > use them across GDB, we can use them locally in files that are > problematic, like this one. > > gdb/ChangeLog: > > * unittests/string_view-selftests.c: Define GNULIB_NAMESPACE. I noticed the exact same problem, and came up with the exact same solution. Sorry for not reporting right away, I have been swamped :-( and also wanted to spend some more time investigating the bigger picture; it seems to me like we may be having a huge time bomb in our hands?!? In other words, either we don't define GNULIB_NAMESPACE, but then we run into unwanted renames of class method names; or we defined GNULIB_NAMESPACE, but that means we must be prefixing all the symbols we call that are covered by the imported part of GNULIB with that namespace. What worries me is that I don't see what's preventing us from hitting that issue outside of the unittests code? We know we can adjust our own classes, but this problem occured with a system class, so we had no choice but to use GNULIB_NAMESPACE. I worry that the transition from no GNULIB_NAMESPACE to using GNULIB_NAMESPACE in a given unit will leave some C system calls that should normally be covered by gnulib silently now reverting to the system (buggy) version. -- Joel