Skip to content

v1.0.1 hangs during compilation of my program on CentOS 6 #8

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

Closed
jvo203 opened this issue Jan 23, 2019 · 14 comments
Closed

v1.0.1 hangs during compilation of my program on CentOS 6 #8

jvo203 opened this issue Jan 23, 2019 · 14 comments
Assignees

Comments

@jvo203
Copy link

jvo203 commented Jan 23, 2019

The previous version 0.3.8 works on CentOS 6, 7, macOS and Ubuntu 18.04 without a hitch. The new version hangs (without any error messages) when called from the build.rs on two separate machines running CentOS 6. All other systems (including CentOS 7) are OK. Downgrading ispc-rs to 0.3.8 in Cargo.toml fixes the problem. The ispc binary is present on my PATH:

ispc --version
Intel(r) SPMD Program Compiler (ispc), 1.9.2 (build commit 417b33ee4ab6ef78 @ 20171111, LLVM 5.0)

This is the initial part of build.rs. For the full source code please see https://github.com/jvo203/fits_web_ql

extern crate bindgen;
extern crate ispc;
extern crate metadeps;

use std::env;
use std::path::PathBuf;

fn main() {
let mut cfg = ispc::Config::new();
cfg.optimization_opt(ispc::opt::OptimizationOpt::FastMath);
cfg.addressing(ispc::opt::Addressing::A32);
let ispc_files = vec!["src/fits.ispc"];
for s in &ispc_files[..] {
cfg.file(*s);
}
cfg.compile("spmd");

(...)

@Twinklebear
Copy link
Owner

Interesting, let me find a CentOS 6 machine to reproduce this with. Thanks for reporting the issue!

@Twinklebear Twinklebear self-assigned this Jan 23, 2019
@Twinklebear
Copy link
Owner

It looks like the machine I found with CentOS 6 has too old a CPU to build some of the crates (ring), but I pulled out most of the dependencies to just try getting the build script and ISPC code to compile, and it does look to build the ISPC code successfully, but then fails to find a recent enough vpx version on the machine.

Could you check if adding a print and/or exit from the build script here https://github.com/jvo203/fits_web_ql/blob/master/build.rs#L17 gives you some output? Since it hangs, maybe do an abort there, and let me know if it prints? The build script to test could look like:

extern crate bindgen;
extern crate ispc;
extern crate metadeps;

use std::process;
use std::env;
use std::path::PathBuf;

fn main() {
    let mut cfg = ispc::Config::new();
    cfg.optimization_opt(ispc::opt::OptimizationOpt::FastMath);
    cfg.addressing(ispc::opt::Addressing::A32);
    let ispc_files = vec!["src/fits.ispc"];
    for s in &ispc_files[..] {
        cfg.file(*s);
    }
    cfg.compile("spmd");
    println!("cargo:warning=Done compiling ISPC");
    std::process::exit(1);

    // rest of script
}

@jvo203
Copy link
Author

jvo203 commented Jan 24, 2019

As per your reply the develop branch of build.rs now contains
println!("cargo:warning=Done compiling ISPC");
std::process::exit(1);

on CentOS 6 the compilation hangs indefinitely without printing "Done compiling ISPC":

Compiling fits_web_ql v4.1.0 (/mnt/data/chris/projects/fits_web_ql)
warning: unreachable statement
--> build.rs:20:5
|
20 | println!("cargo:rustc-link-search=native=/usr/local/lib");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unreachable_code)] on by default
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

Compiling actix v0.7.9
Compiling actix-net v0.2.6
Compiling actix-web v0.7.18
Building [=====================================================> ] 353/355: fits_web_ql(build)

replacing ispc = "*" with ispc = "0.3.8" in Cargo.toml fixes the problem immediately:

[chris@capricorn fits_web_ql]$ git pull
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From https://github.com/jvo203/fits_web_ql
5df1245..58901ba develop -> origin/develop
Updating 5df1245..58901ba
Fast-forward
Cargo.toml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[chris@capricorn fits_web_ql]$ cargo run --features 'server cdn opencl' --release
Updating crates.io index
Downloaded ispc v0.3.8
Downloaded bindgen v0.43.2
Downloaded bindgen v0.46.0
Downloaded clang-sys v0.26.4
Downloaded proc-macro2 v0.3.5
Downloaded quote v0.5.2
Downloaded which v1.0.5
Compiling which v1.0.5
Compiling clang-sys v0.26.4
Compiling bindgen v0.43.2
Compiling bindgen v0.46.0
Compiling ispc v0.3.8
Compiling fits_web_ql v4.1.0 (/mnt/data/chris/projects/fits_web_ql)
warning: unreachable statement
--> build.rs:20:5
|
20 | println!("cargo:rustc-link-search=native=/usr/local/lib");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unreachable_code)] on by default
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: failed to run custom build command for fits_web_ql v4.1.0 (/mnt/data/chris/projects/fits_web_ql)
process didn't exit successfully: /mnt/data/chris/projects/fits_web_ql/target/release/build/fits_web_ql-0667dff646cd8595/build-script-build (exit code: 1)
--- stdout
cargo:rerun-if-changed=src/fits.ispc
cargo:warning=Warning: No --target specified on command-line. Using default system target
cargo:warning= "avx2-i32x8".
cargo:warning=src/fits.ispc:349:15: Performance Warning: Conversion from unsigned int to
cargo:warning= float is slow. Use "int" if possible
cargo:warning= float r = _r[j];
cargo:warning= ^^^^^
cargo:warning=
cargo:warning=src/fits.ispc:350:15: Performance Warning: Conversion from unsigned int to
cargo:warning= float is slow. Use "int" if possible
cargo:warning= float g = _g[j];
cargo:warning= ^^^^^
cargo:warning=
cargo:warning=src/fits.ispc:351:15: Performance Warning: Conversion from unsigned int to
cargo:warning= float is slow. Use "int" if possible
cargo:warning= float b = _b[j];
cargo:warning= ^^^^^
cargo:warning=
cargo:warning=src/fits.ispc:341:5: Performance Warning: Scatter required to store value.
cargo:warning= dst[dst_index] = clamp( (int)round(pixel / accum), 0, 255) ;
cargo:warning= ^^^^^^^^^^^^^^
cargo:warning=
cargo:warning=src/fits.ispc:335:18: Performance Warning: Gather required to load value.
cargo:warning= pixel += src[src_index] * coeff ;
cargo:warning= ^^^^^^^^^^^^^^
cargo:warning=
cargo:rerun-if-changed=src/fits.ispc
cargo:rustc-link-lib=static=spmd
cargo:rustc-link-search=native=/mnt/data/chris/projects/fits_web_ql/target/release/build/fits_web_ql-d2d3eacfe0ff1ca6/out
cargo:rustc-link-search=native=/mnt/data/chris/projects/fits_web_ql/target/release/build/fits_web_ql-d2d3eacfe0ff1ca6/out
cargo:warning=Done compiling ISPC

--- stderr
error: 'rustfmt' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'
To install, run rustup component add rustfmt
Custom { kind: Other, error: StringError("Internal rustfmt error") }

There seems to be something inherently different between 0.3.8 and the newer version 1.0.X ...

@jvo203
Copy link
Author

jvo203 commented Jan 24, 2019

After cloning ispc-rs to a local folder on CentOS 6 I've used git bisect to help narrow down the source of the problem. Here is the full output. Hope it helps! Our other CentOS 6 server is a production server so definitely it would help if a fix can be found. For the time being the ispc-rs version has been downgraded to 0.3.8 in the master branch of fits_web_ql.

[chris@capricorn ~]$ cd projects/ispc-rs/
[chris@capricorn ispc-rs]$ git branch

  • master
    [chris@capricorn ispc-rs]$ git bisect start
    [chris@capricorn ispc-rs]$ git bisect bad
    [chris@capricorn ispc-rs]$ git bisect good 0.3.8
    Bisecting: 15 revisions left to test after this (roughly 4 steps)
    [40646dd] fix typo in readme
    [chris@capricorn ispc-rs]$ git bisect good
    Bisecting: 7 revisions left to test after this (roughly 3 steps)
    [76818f5] docs and versions for release of new split crates
    [chris@capricorn ispc-rs]$ git bisect bad
    Bisecting: 4 revisions left to test after this (roughly 2 steps)
    [4f9876b] restructure docs
    [chris@capricorn ispc-rs]$ git bisect good
    Bisecting: 2 revisions left to test after this (roughly 1 step)
    [93ed90e] ispc tarball dir structure changed
    [chris@capricorn ispc-rs]$ git bisect good
    Bisecting: 0 revisions left to test after this (roughly 1 step)
    [a447345] Merge remote-tracking branch 'origin/master' into packaging
    [chris@capricorn ispc-rs]$ git bisect good
    76818f5 is the first bad commit
    commit 76818f5
    Author: Will Usher [email protected]
    Date: Tue Jan 22 21:28:42 2019 -0700

    docs and versions for release of new split crates

:100644 100644 2df45f0e35fa980b3e3cc2e379a707d74da9f1a7 cf19ebc8dc96f67c4ee7b558d252e4de0d4e7031 M Cargo.toml
:040000 040000 171bb9fe0fb2f899d6769374166f19d3ddda3cf2 5c55295592c52ab308283121d972402ff75dd25a M compile
:040000 040000 be649f822557209cd95a7dcb652fc1da74d1d29b 95dcbc171bec7ff5558df3eaeb302588cfcab5f8 M runtime
:040000 040000 e94a201b4be974f76952bff6bd0d5abdc1957614 c3c91ab275b4ad5a73aee4438fdcd17c06560731 M src

@Twinklebear
Copy link
Owner

The bisect helps a lot, thank you for doing it! I'm wondering if the issue is maybe that the bindgen libraries used by ispc-rs and your project are conflicting somehow? In the bad commit (76818f5#diff-29c19683a99ab5fee09f5429920200e5R28) the only real change is updating the dependencies. I updated to use bindgen 0.47.0, though in your project's Cargo.toml it takes any version, so it may be using some older version and conflicting? Would you mind trying to build on 1.0.2 again after doing a cargo update?

If that doesn't work I'll look at getting some of the out of date dependencies updated on our CentOS 6 machine to reproduce the build. As a note, I am able to build the ispc-rs examples on the CentOS 6 machine we have.

@jvo203
Copy link
Author

jvo203 commented Jan 24, 2019

I do "cargo update" on a regular basis. Re-setting the local ispc-rs repository to 1.0.2 and doing "cargo update" on fits_web_ql does not help, the build hangs indefinitely. The CentOS 6 is up-to-date. The only exception is the kernel version, kept at 3.10 for KNC Xeon Phi compatibility.

[chris@capricorn ispc-rs]$ cat /etc/redhat-release
CentOS release 6.10 (Final)

[chris@capricorn ispc-rs]$ ldd --version
ldd (GNU libc) 2.12
Copyright (C) 2010 Free Software Foundation, Inc.

[chris@capricorn ispc-rs]$ uname -a
Linux capricorn.vo.nao.ac.jp 3.10.108-1.el6.elrepo.x86_64 #1 SMP Sun Nov 5 10:54:49 EST 2017 x86_64 x86_64 x86_64 GNU/Linux

[chris@capricorn fits_web_ql]$ cargo update
Updating crates.io index
Removing bindgen v0.43.2
Removing bindgen v0.46.0
Adding bindgen v0.47.0
Updating clang-sys v0.26.4 -> v0.27.0
Updating ispc v0.3.8 (/mnt/data/chris/projects/ispc-rs) -> v1.0.2
Updating ispc_compile v0.3.8 (/mnt/data/chris/projects/ispc-rs/compile) -> v1.0.2
Updating ispc_rt v0.3.8 (/mnt/data/chris/projects/ispc-rs/runtime) -> v1.0.1
Removing proc-macro2 v0.3.5
Removing quote v0.5.2
Removing which v1.0.5
[chris@capricorn fits_web_ql]$ cargo run --features 'server cdn opencl' --release
Compiling ispc_rt v1.0.1 (/mnt/data/chris/projects/ispc-rs/runtime)
Compiling ispc_compile v1.0.2 (/mnt/data/chris/projects/ispc-rs/compile)
Compiling ispc v1.0.2 (/mnt/data/chris/projects/ispc-rs)
Compiling fits_web_ql v4.1.0 (/mnt/data/chris/projects/fits_web_ql)
warning: unreachable statement
--> build.rs:20:5
|
20 | println!("cargo:rustc-link-search=native=/usr/local/lib");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unreachable_code)] on by default
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

^C Building [=====================================================> ] 353/355: fits_web_ql(build)

@jvo203
Copy link
Author

jvo203 commented Jan 24, 2019

I manually edited Cargo.toml in the local ispc-rs repository version 0.3.8. Changing bindgen from 0.43 to 0.47 is the single cause of the freezes. But why would that be a problem on CentOS 6 if it does not cause any problems on other platforms (CentOS 7 is OK too)? I always use "cargo update" to keep everything up to date, the Rust version is 1.32.

[package]
name = "ispc"
version = "0.3.8-test"

[dependencies]
bindgen = "0.47"

@Twinklebear
Copy link
Owner

Interesting, it seems to not be a version conflict but some issue in bindgen on CentOS 6? Reverting to bindgen 0.43 would be fine with me, I've just been updating it with new releases to keep on the latest version, but the changes from 0.43 to 0.47 (partly listed in https://github.com/rust-lang/rust-bindgen/blob/master/CHANGELOG.md#0470) shouldn't make a big difference for generating the ispc bindings.

Thanks for helping to track this issue down! If you have some more time and find the latest bindgen after 0.43 which doesn't hang let me know and I'll update to that version, otherwise I'll stick with 0.43

@jvo203
Copy link
Author

jvo203 commented Jan 24, 2019

Could it be caused by this bindgen change (Update clang-sys #1489)?

rust-lang/rust-bindgen#1489

Anyway, out of sheer curiosity I will try git-bisecting rust-bindgen to see what might be causing the problem. It is very perplexing... v0.43.2 works OK (pulled by ispc-rs 0.3.8).

@jvo203
Copy link
Author

jvo203 commented Jan 24, 2019

Have git-bisected rust-bindgen. Indeed the problem can be traced to (Update clang-sys #1489) rust-lang/rust-bindgen#1489

Bad commit:

rust-lang/rust-bindgen@271dc73

[chris@capricorn rust-bindgen]$ git bisect start
[chris@capricorn rust-bindgen]$ git bisect bad
[chris@capricorn rust-bindgen]$ git bisect good v0.43.2
Bisecting: 33 revisions left to test after this (roughly 5 steps)
[6bb16ba6971601ffe277830344552ba71e431b52] regex_set: Derive Default instead of manually implementing it.
[chris@capricorn rust-bindgen]$ git bisect good
Bisecting: 16 revisions left to test after this (roughly 4 steps)
[ad1ce8afb3332e478f41bc81e10cbfd0eb4a7a62] Remove deprecated calls to trim_(right|left)_matches
[chris@capricorn rust-bindgen]$ git bisect good
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[0d004a726d932cec27d94499e48bc7e3943cb457] Merge pull request #1489 from KyleMayes/clang-sys
[chris@capricorn rust-bindgen]$ git bisect bad
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[28c0eb4505865220d6f2a8f779f5876dc753feac] Merge pull request #1484 from LegNeato/patch-1
[chris@capricorn rust-bindgen]$ git bisect good
Bisecting: 1 revision left to test after this (roughly 1 step)
[2a01e8d499d71e596e4b02f8fd6897f061405e1a] Merge pull request #1485 from LegNeato/packed
[chris@capricorn rust-bindgen]$ git bisect good
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[271dc738381650cb09cabca11625eece29826f19] Update clang-sys
[chris@capricorn rust-bindgen]$ git bisect bad
271dc738381650cb09cabca11625eece29826f19 is the first bad commit
commit 271dc738381650cb09cabca11625eece29826f19
Author: Kyle Mayes [email protected]
Date: Sat Jan 12 08:48:37 2019 -0500

Update clang-sys

:100644 100644 dae460fd65e054493f59000002c7373eda1f9873 47927a6a9c196b7df5f5e29cb81ac0bb178c7e8a M Cargo.lock
:100644 100644 9f892854c694ab5a80ce191f3cb87e70b84c6af4 39aafe10a9cec5aa46d37ce41e4ab981c85a6495 M Cargo.toml

@Twinklebear
Copy link
Owner

Interesting, I wonder if the "load functions until the version can be determined" mentioned in the PR for that commit is what's causing the hang, and somehow it gets into some infinite loop trying to do this or fails to determine the version.

It looks like that commit is part of 0.47, so 0.46 should be ok. I'll update ispc-rs to use 0.46, thanks again for your help tracking this down!

@Twinklebear
Copy link
Owner

Could you try out ispc 1.0.3 and let me know if that resolves the hang for you? You may also want to explicitly pick the bindgen version you're using in your Cargo.toml to also be 0.46.0

@jvo203
Copy link
Author

jvo203 commented Jan 25, 2019

Setting ispc = "*" together with the latest version of your crate now leads to a successful compilation on CentOS 6 without any hanging. Thank you. I guess bindgen and/or clang-sys developers should be made aware of this issue.

@Twinklebear
Copy link
Owner

That's good to hear! I wonder what changed in clang-sys to cause it, the load symbols change doesn't seem like it would cause a hang, but I'm not sure.

I'll close this issue, thanks again for your help debugging this!

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