From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id B00E23858038 for ; Fri, 30 Apr 2021 01:55:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B00E23858038 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jimw@sifive.com Received: by mail-ed1-x52e.google.com with SMTP id c22so17183755edn.7 for ; Thu, 29 Apr 2021 18:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3UL7sIY6pJI8qR2rvjG278JYIMguT4TixvwQcG5pImQ=; b=NROgQatmiJk6TWymjW1ZAfYNMc5jjrmsYyIzX19va4Nu0sPxl7GS2fQILdUOLDB4vV 3H8kg1B4sc1zBTwZdJ55lYaCUR5qMLGeFjDPELjjm0W4FSpbNWKU5lfsyLzi661teg6k sGqBqLsC8majs77B5xc2FOtl/QgoJ67RKp6B6V4++KSNGQFFQACtCshmlObVFzaGYx6j pe6rfgcO3/JHlav+Z+VISHrbelBfvifH+uaR5/MdZOYrWE9KltrVBE2ZC0qNSJpNZqb/ iZE8CwHNlYhxCIPQPJ0Cms6ZOBG5OD3ZQxRU7DHuxspxAZh6Ah6pgjEBZH7x0tiepOzx CZBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3UL7sIY6pJI8qR2rvjG278JYIMguT4TixvwQcG5pImQ=; b=T5c28GXz3HTmQVZhCYO8v+bhj81HQs10Rc1wVH7Jr4of1Uv4nZFIESh24OpDW9Fbvy Aofj0G1pKwKmUooQSjHqKgYPfVOYpMuvaecPMFDRopuMiUM5GF9Gg5QlvQXPjNFF3I2p F9D6afbiFFcqyQXqXzeuxbXx3mXf8Y1CtVOMSISM7afJDPxb7HlKDwS1FvXU0uLueCUa jGyu1xyeOYlEcgMt3Drzb5OB+KksZXp2ZK4gBMvHJ0Qp1oaIfImIJnjp0wqlKnvrmyej 81CCinxVb1XwizlPM9mkzJgkvcV6QrdKIO4eGsvr7bHVtDigjF+FPfTLrwi2dWwlagV8 KT6A== X-Gm-Message-State: AOAM530Ulweu5nImAW89KkmwmhEEIBJ8T1MGZC0c4TWjEgs+wVUNlchE YuEF+m5ssTT3M8+pmz7ZMCPMdVN5X4YeSQ6pLxHmSzJjMKGTow== X-Google-Smtp-Source: ABdhPJxjugytTbKPZ3aNzhahCIi+oyme8yJ7F7S99lfQCkhKdNoWpHiorO3pnPefc6cs7y6EijEHQUDRolbh+9XFyXE= X-Received: by 2002:aa7:c34b:: with SMTP id j11mr3009866edr.188.1619747745625; Thu, 29 Apr 2021 18:55:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jim Wilson Date: Thu, 29 Apr 2021 18:55:34 -0700 Message-ID: Subject: Re: About implementation of the Negative property of options. To: Joseph Myers Cc: gengqi-linux , gcc-patches X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2021 01:55:49 -0000 On Wed, Apr 28, 2021 at 1:11 PM Joseph Myers wrote: > Could you please explain the bug at the *user-visible* level? That is, > the particular options passed to the compiler, how those options behave, > and how you think they should behave instead. I added this to the riscv.opt file to create some new options for demonstration purposes. The same changes probably work for other targets too. mfoo1= Target Joined Var(riscv_isa_foo) mfoo2= Target Joined Var(riscv_isa_foo) RejectNegative mfoo3= Target Joined Var(riscv_isa_foo) Negative(mfoo3=) mfoo4= Target Joined Var(riscv_isa_foo) Negative(mfoo5=) mfoo5= Target Joined Var(riscv_isa_foo) Negative(mfoo4=) mfoo6= Target Joined Var(riscv_isa_foo) Negative(mfoo6=) RejectNegative mfoo7= Target Joined Var(riscv_isa_foo) Negative(mfoo8=) RejectNegative mfoo8= Target Joined Var(riscv_isa_foo) Negative(mfoo7=) RejectNegative TargetVariable int riscv_isa_foo = 0 Then I ran some commands to look at the cc1 option list. rohan:2754$ ./xgcc -B./ -mfoo1=10 -mfoo1=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo1=10 -mfoo1=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2755$ ./xgcc -B./ -mfoo2=10 -mfoo2=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo2=10 -mfoo2=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2756$ ./xgcc -B./ -mfoo3=10 -mfoo3=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo3=10 -mfoo3=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2757$ ./xgcc -B./ -mfoo4=10 -mfoo4=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo4=10 -mfoo4=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2758$ ./xgcc -B./ -mfoo5=10 -mfoo5=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo5=10 -mfoo5=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2759$ ./xgcc -B./ -mfoo6=10 -mfoo6=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo6=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2760$ ./xgcc -B./ -mfoo7=10 -mfoo7=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo7=10 -mfoo7=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2761$ ./xgcc -B./ -mfoo7=10 -mfoo8=20 tmp.c -v -S |& grep cc1 ./cc1 -quiet -v -imultilib rv64imafdc/lp64d -iprefix /home/jimw/FOSS/GCC/X-9-riscv64-elf/gcc/../lib/gcc/riscv64-unknown-elf/9.3.1/ -isystem ./include -isystem ./include-fixed tmp.c -quiet -dumpbase tmp.c -mfoo7=10 -mfoo8=20 -march=rv64gc -mabi=lp64d -auxbase tmp -version -o tmp.s rohan:2762$ Note that only in the -mfoo6= case are the duplicate options removed from the command line. So pruning options requires that you have both RejectNegative and Negative pointing at yourself, which is not what the documentation says. The original bug report mentioned problems with picking the right multilib if you have multiple conflicting options on the command line. But another simpler way to show the problem is by mixing 32-bit and 64-bit arches on the command line. rohan:2546$ riscv64-unknown-elf-gcc -march=rv32gc -march=rv64gc -mabi=lp64d tmp.c /home/jimw/FOSS/install-riscv64/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: unrecognised emulation mode: elf3264lriscv Supported emulations: elf64lriscv elf32lriscv collect2: error: ld returned 1 exit status rohan:2547$ This is because we have #define XLEN_SPEC \ "%{march=rv32*:32}" \ "%{march=rv64*:64}" \ #define LINK_SPEC "\ -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv \ which only works right if contradictory options are pruned. I tried a gcc-9 tree that I have handy, and got the same result. Only in the -mfoo6= case are the contradictory options pruned away, so this does not appear to be due to a recent change, but rather has been working this way for a while. For the RISC-V port, adding the missing Negative lines to the riscv.opt file is easy enough, I will just go ahead and do that. But we might want to consider whether this design is correct, and how to fix the docs to match reality. Jim