Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic computing autodiff attributes of <&T as core::fmt::Debug>::fmt #183

Closed
jedbrown opened this issue Oct 28, 2024 · 8 comments
Closed

Comments

@jedbrown
Copy link

Code

This occurs while building rustc at 012062a. I used the config.toml below and did a clean rebuild x build --stage 1 library after deleting my build directory.

# Use different pre-set defaults than the global defaults.
#
# See `src/bootstrap/defaults` for more information.
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
profile = 'dist'
change-id = 129176

[llvm]

# Indicates whether the LLVM assertions are enabled or not
# NOTE: When assertions are disabled, bugs in the integration between rustc and LLVM can lead to
# unsoundness (segfaults, etc.) in the rustc process itself, not just in the generated code.
assertions = true

# Indicates whether the LLVM plugin is enabled or not
plugins = true

# Whether to use Ninja to build LLVM. This runs much faster than make.
ninja = true

# Whether to build LLVM as a dynamically linked library (as opposed to statically linked).
# Under the hood, this passes `--shared` to llvm-config.
# NOTE: To avoid performing LTO multiple times, we suggest setting this to `true` when `thin-lto` is enabled.
link-shared = true

# Whether to build the clang compiler.
clang = true

# Whether to build Enzyme as AutoDiff backend.
enzyme = true

[build]

# Whether to build documentation by default. If false, rustdoc and
# friends will still be compiled but they will not be used to generate any
# documentation.
#
# You can still build documentation when this is disabled by explicitly passing paths,
# e.g. `x doc library`.
docs = false

# Arguments passed to the `./configure` script, used during distcheck. You
# probably won't fill this in but rather it's filled in by the `./configure`
# script. Useful for debugging.
configure-args = ['--enable-llvm-link-shared', '--enable-llvm-plugins', '--enable-llvm-enzyme', '--release-channel=nightly', '--enable-llvm-assertions', '--enable-clang', '
--enable-lld', '--enable-option-checking', '--enable-ninja', '--disable-docs']

[install]

[rust]
debug = true
#debuginfo-level = 2

# The "channel" for the Rust build to produce. The stable/beta channels only
# allow using stable features, whereas the nightly and dev channels allow using
# nightly features
channel = 'nightly'

# Indicates whether LLD will be compiled and made available in the sysroot for
# rustc to execute.
lld = true

# Indicates whether the `self-contained` llvm-bitcode-linker, will be made available
# in the sysroot. It is required for running nvptx tests.
llvm-bitcode-linker = true

[target.x86_64-unknown-linux-gnu]

[dist]

Error output

thread 'rustc' panicked at /home/jed/src/rust-enzyme/compiler/rustc_middle/src/ty/mod.rs:1782:13:
assertion failed: rustc_feature::encode_cross_crate(attr)
[...]

rustc version: 1.84.0-nightly (012062a3d 2024-10-27)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [autodiff_attrs] computing autodiff attributes of `<&T as core::fmt::Debug>::fmt`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Full trace: rustc-ice-2024-10-28T18_58_06-3594632.txt

@ZuseZ4
Copy link
Member

ZuseZ4 commented Oct 28, 2024

What OS are you on? I couldn't reproduce it on 3 different systems.

@jedbrown
Copy link
Author

Arch Linux and Debian (reproduced on both systems), both x86-64.

@ZuseZ4
Copy link
Member

ZuseZ4 commented Oct 29, 2024

I don't have these three, maybe try without?

[rust]
debug = true
llvm-bitcode-linker = true
lld = true

Independently, try to change

EncodeCrossCrate::No to EncodeCrossCrate::Yes in compiler/rustc_feature/src/builtin_attrs.rs line ~756

@ZuseZ4
Copy link
Member

ZuseZ4 commented Oct 29, 2024

potentially related: rust-lang#129458 (comment)

@jedbrown
Copy link
Author

Removing debug = true works on both machines and I can run the samples and integration tests in rustbook (great). I'm having trouble tracking down how to activate the new enzyme-loose-types key with rust.

@ZuseZ4
Copy link
Member

ZuseZ4 commented Oct 29, 2024

@jedbrown
Copy link
Author

Thanks. Seems to work (accepts the option), but rustbook/samples-loose-types is currently failing

Illegal updateAnalysis prev:{[-1]:Pointer, [-1,-1]:Integer} new: {[-1]:Pointer, [-1,0]:Float@double}
val:   %10 = getelementptr inbounds [6 x double], ptr %3, i64 0, i64 2, !dbg !254 origin=  store double %29, ptr %10, align 8, !dbg !254, !alias.scope !261, !noalias !264

error: could not compile `samples-loose-types` (test "mod")

after setting

diff --git c/samples-loose-types/tests/neohookean/mod.rs w/samples-loose-types/tests/neohookean/mod.rs
index e122c81..234ee75 100644
--- c/samples-loose-types/tests/neohookean/mod.rs
+++ w/samples-loose-types/tests/neohookean/mod.rs
@@ -3,6 +3,7 @@

 #![allow(non_snake_case)]

+use std::autodiff::autodiff;
 use std::ops::{Add, Mul, Sub};

 type Mat3x3 = [[f64; 3]; 3];

This is low priority and perhaps that example needs more changes (it uses second derivatives).

@ZuseZ4
Copy link
Member

ZuseZ4 commented Nov 25, 2024

closing, since the original bug was fixed. If the higher order persists after moving to the pass approach you can open a new issue (though probably against enzyme core).

@ZuseZ4 ZuseZ4 closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants