From nobody Sun Jun 5 08:26:37 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 983B41BD072C for ; Sun, 5 Jun 2022 08:27:03 +0000 (UTC) (envelope-from nyan@myuji.xyz) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4LG8qS12rmz4q9C for ; Sun, 5 Jun 2022 08:26:59 +0000 (UTC) (envelope-from nyan@myuji.xyz) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 79CC65C00B0 for ; Sun, 5 Jun 2022 04:26:59 -0400 (EDT) Received: from imap45 ([10.202.2.95]) by compute4.internal (MEProxy); Sun, 05 Jun 2022 04:26:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=myuji.xyz; h=cc :content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm1; t= 1654417619; x=1654504019; bh=1h3UmYbXKFTcNFQb3AT2oqnoTzH3a1RGggW jYxgYtPc=; b=apZIRIVE8sZuRtkgg4RYEdyxJt5FOzjYPBRa3Sqd86NTRoc4tUs AqxJ0m82kamq2O3gJlljhLB/DDlOHKeV05QAjPVlKeoTkjWYb1Zu9+b69ifHSJ3Q pR0wTN/0bE5Ib3dKsYkELPMb0ERCVfjdESXC1ErFBT3YKRUanrF0cGMnTRI3+Ywc RCcZWs5acjEQs08Rqi4WZ5BiBIQ9qxjjBtqkat5ucDYyAE2HQDMjOrK4lThBZdZB mSjGPh1mR466zQTqgVpaQeTOZ98Db5XL8jeC9bdqvh8wPzeRAjo0SwWG2P62iA9S bW0bk4M/2Jz/CY7tHr0wsheufWOy/kEE8yw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1654417619; x= 1654504019; bh=1h3UmYbXKFTcNFQb3AT2oqnoTzH3a1RGggWjYxgYtPc=; b=i 5xlLjz5kMY0JfGjei6mu+I+YnqcI3aH/rSOL8hQTcLWD276SAsqXyMnx2/4tRtvP tQL8gUqtCr92Cx5Z/Acsadg2XYM5wfBMlCdBs5OiVp0NmS9M0RAjwTazdhH+jn0Z IL+65fZJtK+T33sMzAT2FGwJowXwsDuC0lBUmYcrPeyTMoyOD+/3veonw1AluVqs dfC2NvEJdwjVxgf/WIqszFWyG1R705oa8doNx3TeLTg+/4Cj0SZmdjt9ADzv4ryy PpKa2y2x5nAjlgp4rYZq33BD1kw6YsTV1uiucShBnIRzBXmMp8hYuLslqCH3rXYx laaqnZldKtqOS6Lb4qgJA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddttddgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdlfeehmdenucfjughrpefofg ggkfffhffvufgtsegrtderreerreejnecuhfhrohhmpedfofhitghhrggvlhcujggrnhcu mfgrucevhhhiuhdfuceonhihrghnsehmhihujhhirdighiiiqeenucggtffrrghtthgvrh hnpeelieeigfelhedvudeivefhvdfgfeekhffgtdeuhfefuedvuedvgfevfeelieekheen ucffohhmrghinhepghhithhhuhgsrdgtohhmpdhrvggtohhrugdrrhhsnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhihrghnsehmhihujhhi rdighiii X-ME-Proxy: Feedback-ID: i9dd946d0:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3A3702720072; Sun, 5 Jun 2022 04:26:59 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-591-gfe6c3a2700-fm-20220427.001-gfe6c3a27 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 Message-Id: Date: Sun, 05 Jun 2022 16:26:37 +0800 From: "Michael Yan Ka Chiu" To: freebsd-hackers@FreeBSD.org Subject: Help needed to get Rust dtrace USDT working on/with FreeBSD linker Content-Type: multipart/alternative; boundary=85fc6e84595f46b0831dedca9d529307 X-Rspamd-Queue-Id: 4LG8qS12rmz4q9C X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=myuji.xyz header.s=fm1 header.b=apZIRIVE; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="i 5xlLjz"; dmarc=none; spf=pass (mx1.freebsd.org: domain of nyan@myuji.xyz designates 66.111.4.27 as permitted sender) smtp.mailfrom=nyan@myuji.xyz X-Spamd-Result: default: False [-3.59 / 15.00]; XM_UA_NO_VERSION(0.01)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:66.111.4.27]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[myuji.xyz:+,messagingengine.com:+]; NEURAL_HAM_SHORT(-1.00)[-0.999]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:19151, ipnet:66.111.4.0/24, country:US]; RCVD_IN_DNSWL_LOW(-0.10)[66.111.4.27:from]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[myuji.xyz:s=fm1,messagingengine.com:s=fm1]; FREEFALL_USER(0.00)[nyan]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[myuji.xyz]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[messagingengine.com:dkim]; MLMMJ_DEST(0.00)[freebsd-hackers]; MID_RHS_WWW(0.50)[] X-ThisMailContainsUnwantedMimeParts: N --85fc6e84595f46b0831dedca9d529307 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi everyone, I=E2=80=99m working on a PR to get the Rust Usdt crate working on FreeBS= D. This crate basically allow adding DTrace probes to rust sources by compiling the pr= obe during macro invocation and embed to a custom section (set_dtrace_probe) using = inline=20 assembly. The problem I am encountering is that the linker will optimize the compi= led probes out in the custom section, the only workaround I have found is to force = the linker to link all the dead code by invoking `-C link-dead-code=3Dyes`. On Illumos= , the workaround is to reference another section such that the Illumos linker will not th= row the probes=20 away; however the same workaround does not work on FreeBSD. I wonder if there're any tricks similar to the Illumos fix, by putting s= ome inline asm there to trick the linker and not throw out the probes. Thanks In advance, Michael References: The PR: https://github.com/oxidecomputer/usdt/pull/63 The illumos fix: https://github.com/oxidecomputer/usdt/blob/eac0fe5f03c3= fbf23468ead5cb140f62d51ac3f3/usdt-impl/src/record.rs#L251 =20 --85fc6e84595f46b0831dedca9d529307 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi everyon= e,

I=E2=80=99m working on a PR to get the R= ust Usdt crate working on FreeBSD. This crate
basically al= low adding DTrace probes to rust sources by compiling the probe during
macro invocation and embed to a custom section (set_dtrace_= probe) using inline
assembly.

The problem I am encountering is that the linker will optimize the com= piled probes
out in the custom section, the only workaroun= d I have found is to force the linker to
link all the dead= code by invoking `-C link-dead-code=3Dyes`. On Illumos, the workaround<= br>
is to reference another section such that the Illumos link= er will not throw the probes
away; however the same worka= round does not work on FreeBSD.

I wonder if= there're any tricks similar to the Illumos fix, by putting some inline = asm there
to trick the linker and not throw out the probes= .

Thanks In advance,
Michael


--85fc6e84595f46b0831dedca9d529307--