servo: mozjs-0.8.0 compilation error

Recently rebased off master, now getting an error with ./mach check that strangely arises from mozjs

error[E0277]: the trait bound `u8: std::convert::From<rust::MutableHandle<'_, u8>>` is not satisfied                                                             
    --> /mozjs-0.8.0/src/rust.rs:1205:52
     |
1205 |             wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*);
     |                                                    ^^^^ the trait `std::convert::From<rust::MutableHandle<'_, u8>>` is not implemented for `u8`
     | 
    ::: /mozjs-0.8.0/src/jsapi_wrappers.in:44:1
     |
44   | wrap!(jsapi: pub fn FinishMultiOffThreadScriptsDecoder(cx: *mut JSContext, token: *mut ::std::os::raw::c_void, scripts: MutableHandle<ScriptVector>) -> bool);
     | -------------------------------------------------------------------------------------------------------------------------------------------------------------- in this macro invocation
     |
     = help: the following implementations were found:
               <u8 as std::convert::From<bool>>
     = note: required because of the requirements on the impl of `std::convert::Into<u8>` for `rust::MutableHandle<'_, u8>`

error[E0277]: the trait bound `u8: std::convert::From<rust::MutableHandle<'_, u8>>` is not satisfied
    --> /mozjs-0.8.0/src/rust.rs:1348:113
     |
1348 |             wrap!(@inner $saved <> ($($declargs)* $arg: &mut MutableHandle<$gentype> , )  <> ($($acc,)* (*$arg).into(),) <> $($rest)*);
     |                                                                                                                 ^^^^ the trait `std::convert::From<rust::MutableHandle<'_, u8>>` is not implemented for `u8`
     | 
    ::: /mozjs-0.8.0/src/jsapi_wrappers.in:44:1
     |
44   | wrap!(jsapi: pub fn FinishMultiOffThreadScriptsDecoder(cx: *mut JSContext, token: *mut ::std::os::raw::c_void, scripts: MutableHandle<ScriptVector>) -> bool);
     | -------------------------------------------------------------------------------------------------------------------------------------------------------------- in this macro invocation
     |
     = help: the following implementations were found:
               <u8 as std::convert::From<bool>>
     = note: required because of the requirements on the impl of `std::convert::Into<u8>` for `rust::MutableHandle<'_, u8>`

error: aborting due to 2 previous errors

Am I missing an update command? I tried with ./mach clean a few times already, also update rustup. Could it be that my machine is using an old rust version despite mach?

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 29 (22 by maintainers)

Most upvoted comments

The above idea works, so I have released v0.27.0 of clang-sys with improved version detection.

This should mean that the most recent version of libclang.so should be selected regardless of which instances of libclang.so have version numbers in their filenames.

I also implemented an assert-minimum feature which causes the build script to panic with a descriptive error message if the most recent version of libclang.so available does not meet the specified minimum version.

The current libclang selection process works as described here.

This works well when there is a versioned instance of libclang that has the minimum version you want, but breaks down when there is a versioned instance of libclang “hiding” the unversioned instance you want or multiple unversioned instances.

The ideal solution would be to somehow determine the version of these unversioned instances of libclang so that the latest (or minimum required) version could be selected without these issues.

An idea I had for this, which would only work when linking dynamically, would be to determine the version of an unversioned instance of libclang by dynamically loading the instance and then attempting to load functions only available on certain versions of libclang.

For example:

  • attempt to load clang_CXIndex_setInvocationEmissionPathOption (only available on 6.0 and later)
  • attempt to load clang_Cursor_isExternalSymbol (only available on 5.0 and later)
  • attempt to load clang_EvalResult_getAsLongLong (only available on 4.0 and later)
  • etc…

I will look into this further and report back.

Removing clang 4.0 also worked for me on Ubuntu 16.04.

I’m not a fan of needing to set a bunch of system variables, but also not a fan of needing to uninstall software from my computer to get a build working. Would be preferable if the system was smarter about finding the most recent version of libclang.

Not sure if @KyleMayes’s pull request solves it. I still needed to remove the old version, but maybe that’s just because I’m building off of master?