Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1261330lfc; Wed, 1 Jun 2022 13:25:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeh15hmGn59u/Y6YJ4iZKRyNoymG3dDGA56/mXPO2FR0ha/DnaiHNDcsKVrjqnAe4TB7e0 X-Received: by 2002:a63:1724:0:b0:3fb:be5d:dccd with SMTP id x36-20020a631724000000b003fbbe5ddccdmr954023pgl.625.1654115138974; Wed, 01 Jun 2022 13:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115138; cv=none; d=google.com; s=arc-20160816; b=VO8ybtgzV5+gkdxMmSXs7X9KNoHBHS2w6874Jx16o/Ga0Stc94xC3q6s5Ok7Z3H/iI QFGSaRa4asGBy94ZRKCDlB8ojR+ajVnOoB/APPO0Uz6ooxP1qziBD0svAaT7pcsnQzvP FxY5r/pk94eeQqcv2PRtAOMNSj3v7zJbA280idkHIFvlmF5LHRzTYH2vh/xx7MaUnYf+ 5/1JTLCyscDA9nNbbw9ovzygg3see0Ecp69cfZ5V73qQp5dlO9rKoJ/1tD30AXBmAOkG lmaS3nRBFtQNMm5XzBBkmK4JNwM27jh9o+V2KkceulYjqe7EjPschI8BVZQ/pfo27w6X wktA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gIwe3AKRbCHeJRE3dPTatS7K/6ILlXUNL6T/HNDhAhU=; b=RJLgHHVmcg+r90pJbuSMX/VzINPwwGRhtE47JM1qx7BykPXDMYHOY8T3gHpQIFWJLL r0lczt7gSRHYqi5PDEH+k3mX46ZpwUz6G93tickE7jaZH7ILkqipPb6COkCwsRem6MH6 89mOo81sk8yryw1uevDJ99SpPK45uDs4o0hUbtWS1KTESsGGEz63fU0ZipV6iwY5vfpc Bo/TIoxzDaQFe2UBFci35nAt4fpMgQ95QLs+eDuiuBXB6Qc5Yo+ldcH2aBc1js+N6SLz yxEIC0tejSKF+DOp6tKMPqEHx6JoW9Nd02dOMJ2TxrEFjGPgsmXto/QeNc/aBPVifpeW qMNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cSzwr5IN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q26-20020a63981a000000b003faec4c8202si2968017pgd.292.2022.06.01.13.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cSzwr5IN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B54CC26144F; Wed, 1 Jun 2022 12:37:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240000AbiE3OIl (ORCPT + 99 others); Mon, 30 May 2022 10:08:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240022AbiE3ODP (ORCPT ); Mon, 30 May 2022 10:03:15 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EDE38AE42; Mon, 30 May 2022 06:40:03 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id a10so11336654ioe.9; Mon, 30 May 2022 06:40:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gIwe3AKRbCHeJRE3dPTatS7K/6ILlXUNL6T/HNDhAhU=; b=cSzwr5INM0XMJMTjfBIFqC6i5S58eV8gcJa/64rR0gDugFmRTU5nQgL16eOHpgeMFI 7AfIC/ykpu26A1o3tWj6uRAXJg8F8QVvcvAIxqOgTwk//2oTGuNDuWVqcGupsqpPcM6T ZRAJqMTcOk2f0Pg5Sqy8051E3rZJH3I33bcAioIyj1QEd+htYi69FlxTGKOOn4GcVjjE pEirF1LZJZUjhxfS+0GnGmUhc97QLgfasJMGHXk9cu2E+2pU6QcPUuPNv5BRpstZpwXX 9NoZsAOpE0EVU3IryTlU5mkC2xM3qI4IbFyk9WdwRkwSVZe45lL2Nx+m0vwWNHCFkswg kaCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gIwe3AKRbCHeJRE3dPTatS7K/6ILlXUNL6T/HNDhAhU=; b=WYIg8OMmIYkzVHmC+9kzLY0xjObj+mPLMJOyPZo7f6F2D+rSiF26LroGFrj0aHIDRM 3xqEUoAn2mZwwVIb+OsePeFu6juFTmIqZ5cGYYYDThvISPG9kMq/8kt/XOTdu/drFDEt WUc7jE3K7vZnz5318hodlrm/21zXVNsVSI2Xgihpa2KfyG7fpPIqpzTI6e0lH/uZwgzn N2zeYyq23YkmpiUCYbKBrNhTo3s8i2EsaqZMQUPQCpTWvUIYy5p0I54k8zJQ/KksqUdJ Q/FhXlPzfXtHXrOBbFilWeQGmlhrgd7bJj4bGOZoUvXiCyUnBpzzNxqAu+MDJpTAEv+2 vbbg== X-Gm-Message-State: AOAM532ZeyYkIg9otTEM8kG6LCrIzWL0+5bqv8lEB9/9DIYcCOkgnPWB /cArgZe4U9pLQ4YqomFuml3pC+F88nM6PCB+No0= X-Received: by 2002:a05:6638:f89:b0:32e:89f4:e150 with SMTP id h9-20020a0566380f8900b0032e89f4e150mr27799661jal.308.1653918002647; Mon, 30 May 2022 06:40:02 -0700 (PDT) MIME-Version: 1.0 References: <20220523020209.11810-1-ojeda@kernel.org> <20220523020209.11810-22-ojeda@kernel.org> In-Reply-To: From: Miguel Ojeda Date: Mon, 30 May 2022 15:39:51 +0200 Message-ID: Subject: Re: [PATCH v7 21/25] Kbuild: add Rust support To: Nick Desaulniers Cc: Miguel Ojeda , Masahiro Yamada , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux , linux-kernel , Jarkko Sakkinen , Alex Gaynor , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho , Michael Ellerman , Sven Van Asbroeck , Gary Guo , Boris-Chengbiao Zhou , Boqun Feng , Douglas Su , Dariusz Sosnowski , Antonio Terceiro , Daniel Xu , Miguel Cano , David Gow , Michal Marek , Russell King , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Linux Kbuild mailing list , Linux ARM , linuxppc-dev , linux-riscv , linux-um@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 26, 2022 at 12:25 AM Nick Desaulniers wrote: > > Is there a reason to not just turn clippy on always? Might be nicer to > start off with good practices by default. :^) The idea crossed my mind too [1], but sadly Clippy disables some optimizations and in general is not intended to be used for normal compilation [2]. [1] https://github.com/rust-lang/rust-clippy/issues/8035 [2] https://github.com/rust-lang/rust-clippy/pull/8037 > Are there *.rmeta directories that we _don't_ want to remove via `make > mrproper`? I'm curious why *.rmeta isn't just part of MRPROPER_FILES? Putting them in `MRPROPER_FILES` would mean only those in a given directory are removed (e.g. the root one), but the idea here is to find them anywhere in the tree, since in the future we may have library crates in different parts of the tree. However, I am not sure I understand your first question in relation with the second one -- if we put them in `MRPROPER_FILES`, that would remove less, not more. > I don't think we need to repeat dir/* here again for rust. The > existing targets listed above (outside this hunk) make sense in both > contexts. The idea here is to document the differences (e.g. `RUSTFMT`) and that we may have other targets in the future that do not apply to C (e.g. MIR dump, if that happens to be useful). But maybe I can fit that in the normal place and make it still look good... I will give it a try. > Does rustc really use .i as a conventional suffix for macro expanded > sources? (The C compiler might use the -x flag to override the guess It is not a conventional suffix at all as far as I am aware. Maybe we should use a different one to aid editors and users anyway, e.g. `.rsi`, similar to `.mi` for Objective-C `.m` files. > it would make based on the file extension; I'm curious if rustc can > ingest .i files or will it warn?) The macro expanded output is not intended to be used as a compilable input, but as a debugging aid only. I can note this there. Having said that, `rustc` accepts the "preprocessed" output in the sense that it will just treat them as normal source files (no flag needed, and e.g. both `.i` and `.rsi` work); however, it may give new diagnostics or may require extra flags to enable some compiler features. From a quick test, I managed to compile a "preprocessed" Rust kernel module with only command-line changes. But if we really wanted to support this, we would need to ask upstream Rust to actually support it. > Are these two kconfigs used anywhere? Not for the moment, but it could still be useful when getting `.config` reports (and we could add it to `LINUX_COMPILER` etc. in the future). > How does enabling or disabling debug info work for rustc? I may have > missed it, but I was surprised to see no additional flags getting > passed to rustc based on CONFIG_DEBUG info. `-Cdebuginfo=` is the one; by default there is no debug info and that option enables it (i.e. it is not just the level but the enablement too). (Note that in userspace, when compiling a common program, you will get some debug info coming from the standard library and other dependencies). > Ah, that explains the host rust build infra. Bravo! Hard coding the > target files was my major concern last I looked at the series. I'm > very happy to see it be generated properly from .config! > > I haven't actually reviewed this yet, but it makes me significantly > more confident in the series to see this approach added. Good job > whoever wrote this. Thanks! I thought Rust would be a nice option for writing hostprogs, though of course for the moment only programs that can assume Rust is there may use it. Note that non-x86 specific options need to be handled properly still (e.g. move things between the arch Makefiles and the hostprog as needed). I would still want to see compilers come to some kind of common format for this as we discussed other times, but... :) > Does `$(READELF) -p .comment foo.o` print anything about which > compiler was used? That seems less brittle IMO. Currently, `rustc` does not add a `.comment` section; but we could ask, I sent [3]. If debug info is enabled, another way is using the `DW_AT_language` attribute, like `pahole` will be doing for a new option we need [4]. However, we would still need a way for the other case. In any case, I am not sure something like `.comment` is less or more brittle -- compilers could in theory change it (e.g. not emitting it), while adding a symbol is something we control. So different kinds of brittleness. [3] https://github.com/rust-lang/rust/pull/97550 [4] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=8ee363790b7437283c53090a85a9fec2f0b0fbc4 Cheers, Miguel