<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15600</bug_id>
          
          <creation_ts>2024-09-19 23:36:26 +0000</creation_ts>
          <short_desc>cargo fails to build for riscv64 target</short_desc>
          <delta_ts>2024-11-25 05:50:10 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>5.1</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>5.2 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Khem Raj">raj.khem</reporter>
          <assigned_to name="Harish Sadineni">Harish.Sadineni</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>sundeep.kokkonda</cc>
    
    <cc>Yash.Shinde</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>Regression (Used to work)</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>99677</commentid>
    <comment_count>0</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2024-09-19 23:36:26 +0000</bug_when>
    <thetext>Compiling 1.79 version of cargo fails to build, also note that I am using meta-clang and TOOLCHAIN = &quot;clang&quot; is set in local.conf

below is the error.

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --&gt; /usr/src/debug/cargo/1.79.0/rustc-1.79.0-src/vendor/dbus-0.9.7/src/ffidisp/connection.rs:298:50
    |
298 |         if r == -1 { Err(e) } else { Ok(unsafe { mem::transmute(r) }) }
    |                                                  ^^^^^^^^^^^^^^
    |
    = note: source type: `i32` (32 bits)
    = note: target type: `DBusRequestNameReply` (64 bits)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --&gt; /usr/src/debug/cargo/1.79.0/rustc-1.79.0-src/vendor/dbus-0.9.7/src/ffidisp/connection.rs:306:50
    |
306 |         if r == -1 { Err(e) } else { Ok(unsafe { mem::transmute(r) }) }
    |                                                  ^^^^^^^^^^^^^^
    |
    = note: source type: `i32` (32 bits)
    = note: target type: `DBusReleaseNameReply` (64 bits)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99680</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-09-20 12:56:48 +0000</bug_when>
    <thetext>Sundeep, this is blocking Khem so can you take a look ASAP.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99700</commentid>
    <comment_count>2</comment_count>
    <who name="Sundeep Kokkonda">sundeep.kokkonda</who>
    <bug_when>2024-09-24 10:34:51 +0000</bug_when>
    <thetext>Sure, we will check and update here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99767</commentid>
    <comment_count>3</comment_count>
    <who name="Harish Sadineni">Harish.Sadineni</who>
    <bug_when>2024-10-04 09:51:18 +0000</bug_when>
    <thetext>Referring to the discussion in this GitHub issue from bellow links , we have opted to use transmute_copy instead of transmute to resolve the issue.
https://github.com/rust-lang/rust/issues/61956#issuecomment-506520426
https://github.com/rust-lang/rust/issues/61956#issuecomment-503626904

proposed fix:
--- a/vendor/dbus-0.9.7/src/ffidisp/connection.rs 
+++ b/vendor/dbus-0.9.7/src/ffidisp/connection.rs
@@ -295,7 +295,7 @@
         let mut e = Error::empty();
         let n = to_c_str(name);
         let r = unsafe { ffi::dbus_bus_request_name(self.conn(), n.as_ptr(), flags, e.get_mut()) };
-        if r == -1 { Err(e) } else { Ok(unsafe { mem::transmute(r) }) }
+        if r == -1 { Err(e) } else { Ok(unsafe { mem::transmute_copy(&amp;r) }) }
     }

     /// Release a name.
@@ -303,7 +303,7 @@
         let mut e = Error::empty();
         let n = to_c_str(name);
         let r = unsafe { ffi::dbus_bus_release_name(self.conn(), n.as_ptr(), e.get_mut()) };
-        if r == -1 { Err(e) } else { Ok(unsafe { mem::transmute(r) }) }
+        if r == -1 { Err(e) } else { Ok(unsafe { mem::transmute_copy(&amp;r) }) }
     }

     /// Add a match rule to match messages on the message bus.
	 

However we are currently experiencing bellow failure when running &quot;bitbake core-image-minimal&quot; with toolchain as clang, regardless of the implementation of the above fix
| Makefile:184: *** Your linker does not support creating PIEs, opensbi requires this..  Stop.
| ERROR: oe_runmake failed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99975</commentid>
    <comment_count>4</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-10-23 14:43:38 +0000</bug_when>
    <thetext>Please explain why switching from transmute() to transmute_copy() as a generic patch would be required to fix a build error that seems to *only* affect riscv64 when using clang. This seems like a bad idea or at least one that requires a clear explanation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100258</commentid>
    <comment_count>5</comment_count>
    <who name="Harish Sadineni">Harish.Sadineni</who>
    <bug_when>2024-11-25 05:50:10 +0000</bug_when>
    <thetext>This issue is fixed with patch from following commit:
https://git.openembedded.org/openembedded-core/commit/?id=b9df8cd8b29064d115dab3bfd1ea14f94a5c0238</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>