From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 2D6F53858D3C for ; Mon, 17 Oct 2022 11:52:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D6F53858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id j7so18076383wrr.3 for ; Mon, 17 Oct 2022 04:52:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oqXX6otTFwS2NqRQTdH3WDHXgRKKz18l1fvHK/mYRqc=; b=xJhdmxY3wxAwtGXg8vI6zT485rchWPt+UG3ESaZkogY/Ab1GwMEODgaGtP5GtDG6jF Px+mRSpAewixFjvKH/LUMulRj4izn+wsN9W1K9JyV/BfsegfPxvdu+aIet+pKXkiRZ/q 9aX4dhNvIBbUlRw5M9/bGh/Yc0WQ+AvOh0RkViM+5VCHsjHZdrM+8d6276RLo4kZfggV i6AxjnBRy1mbs2xCHZj9PrCYVRPxPkzvrmq3FcmfooLYqD+nSIVgREaNQnOo1TtFsEL2 h9vzo9q5LUknWpjx5MNZMuK3wPRrU1z96CIhlekB3lsyYcev09LzxxUJFxiggZfdPuKZ +I1Q== X-Gm-Message-State: ACrzQf2e+gicb24Yl9HtWwgL0QVnvRjOOX8W5tgFHE5+Y8pe4gn37zNG KhP2uQGgCn7iTZNi8nqtOKDxCFR0YE0zOw== X-Google-Smtp-Source: AMsMyM56dKOB3zs9IEjFMiiIb+mp5NhQpaAfEGzb3c+4fOMh7sbzcUmttGwQVk8nA3JVoG/QMpA7Vw== X-Received: by 2002:adf:ff8b:0:b0:22e:3608:d9f4 with SMTP id j11-20020adfff8b000000b0022e3608d9f4mr5731062wrr.221.1666007569545; Mon, 17 Oct 2022 04:52:49 -0700 (PDT) Received: from ?IPv6:2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653? ([2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653]) by smtp.gmail.com with ESMTPSA id x8-20020a5d6508000000b00228dff8d975sm8320799wru.109.2022.10.17.04.52.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Oct 2022 04:52:48 -0700 (PDT) Subject: Re: [PATCH] include: Declare getopt function on old GNU libc To: Tsukasa OI , Tom de Vries Cc: binutils@sourceware.org References: <6e4defd8-b02b-9084-afe6-ba22fe75e3d7@irq.a4lg.com> <8ab93d7a617ad480dd786210f46db0e5aa07d1ac.1665655719.git.research_trasio@irq.a4lg.com> From: Pedro Alves Message-ID: <96f0f54e-3acd-c880-6f12-02f6d037501d@palves.net> Date: Mon, 17 Oct 2022 12:52:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-10-16 2:12 p.m., Tsukasa OI wrote: > On 2022/10/13 20:59, Pedro Alves wrote: >> On 2022-10-13 11:11 a.m., Tsukasa OI via Binutils wrote: >>> On GNU libc <= 2.25, includes with __need_getopt macro >>> defined. That is intended to be a part of GNU libc but >>> actually includes include/getopt.h in this project. >> >> Messy. > > Well, I have to agree. > >> >> Do we really still need this getopt.h header? >> >> gnulib, at: >> >> https://www.gnu.org/software/gnulib/manual/html_node/getopt_002eh.html >> >> says: >> >> "This header file is missing on some platforms: AIX 5.1, HP-UX 11, MSVC 14." >> >> AIX 5.1 is from 2001. >> HP-UX 11 is from 1997. >> We don't support building with MSVC AFAIK. >> >> Can't we just get rid of it? >> > > I feel this is too unsafe to do that Why? Are you aware of any host system that people actually build binutils on that doesn't have a proper getopt declaration? > (unless you assume getopt_long and > getopt_long_only are always available on the system). getopt is supposed to be declared in unistd.h. The .c files that use getopt (not the GNU extensions) could just switch to including that one. Even if there is such a system, I would think that a better fix would be to rename include/getopt.h to something else, and have that header include and/or do whatever else needed to pick the right declarations on the system. A standard header replacement that doesn't #include_next the original is just asking for trouble, like we've run into... > > Even if this patch is unacceptable, I don't want to revert previous > changes to sim/configure{,.ac} either (it's necessary to prevent a build > failure with Clang). It's only necessary because of this hacky include/getopt.h header existing, no?. Why would you want to keep the configure.ac bits if the hacky header with the unprototyped declaration doesn't exist any more? Thanks, Pedro Alves > It's also a hack but to stop using getopt > (entirely) may be an option, changing following files: > > - sim/igen/igen.c > - sim/m32c/main.c > - sim/rl78/main.c > > I mean, we could replace getopt with getopt_long plus dummy longopts. > This way, CentOS (7) regression will (also) be gone. > > What do you think? > > Thanks, > Tsukasa >