facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
27.9k stars 6.21k forks source link

Rocksdb fails to compile on x86 musl #12725

Closed Kladki closed 3 weeks ago

Kladki commented 1 month ago

Note: Please use Issues only for bug reports. For questions, discussions, feature requests, etc. post to dev group: https://groups.google.com/forum/#!forum/rocksdb or https://www.facebook.com/groups/rocksdb.dev

Expected behavior

Rocksdb compiles.

Actual behavior

Fails to compile, with the following error. With this patch we managed to get the error down to this, but we are not sure how to proceed from there.

Steps to reproduce the behavior

  1. Try to compile Rocksdb on an x86 musl system
  2. See error
ajkr commented 1 month ago

There was a related patch, but I couldn't accept it yet because there were a bunch of test failures: #12515

rhubner commented 3 weeks ago

Hello @Kladki, Thank you for reporting this issue. To solve your problem, you need to compile RocksDB on modern CPUs for x32 target with flag PORTABLE=1

Detail answer: RocksDB contains a lot of low-level optimisation with vector instructions. Most of this instruction doesn't work in 32bit mode. Unfortunatelly for example __BMI2__ flag is setup even when you are compiling RocksDB for x86(32bit) target.

For example _bzhi_u64 (declaration). As you can see few lines up, there is macro which enable _bzhi_u64 only on 64bit systems.

Radek

Kladki commented 3 weeks ago

We already build with the portable flag,

rhubner commented 3 weeks ago

Hello @Kladki,

Thank for quick response. I'm little confused with your build system. I can see that you use cmake to generate build configuration for ninja build. But it doesn't look like the ninja build is the one used for final compilation. It looks to me you are using our make file. Also if I check the build log you provided, I can still see the -march=native in Cflags flags.

In you PR, I don't understand why did you deleted cmake --build build link

I don't think you need the patch for util/math.h either. You just need to tell build system to compile with PORTABLE=1 on x86 architectures.

Radek

Kladki commented 3 weeks ago

It's fine anyways, I tried switching to plain old make and then everything started building properly.

18 Jun 2024 09:15:40 Radek Hubner @.***>:

Hello @Kladki[https://github.com/Kladki],

Thank for quick response. I'm little confused with your build system. I can see that you use cmake to generate build configuration for ninja build. But it doesn't look like the ninja build is the one used for final compilation. It looks to me you are using our make file. Also if I check the build log you provided, I can still see[https://gitlab.alpinelinux.org/Kladky/aports/-/jobs/1408180#L224] the -m=native in Cflags flags.

In you PR, I don't understand why did you deleted cmake --build build link[https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/62513/diffs?commit_id=7545f9c053ea2816960b4e38030639c47bf094fd#cda118dd7d6b5cfef62690fdc80b1563d5a3628f_40_41]

I don't think you need the patch for util/math.h either. You just need to tell build system to compile with PORTABLE=1 on x86 architectures.

Radek

— Reply to this email directly, view it on GitHub[https://github.com/facebook/rocksdb/issues/12725#issuecomment-2175486678], or unsubscribe[https://github.com/notifications/unsubscribe-auth/BFX23U6LVJJMKOJPYGUW7P3ZH7UCXAVCNFSM6AAAAABIUZ5T36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZVGQ4DMNRXHA]. You are receiving this because you were mentioned. [Tracking image][https://github.com/notifications/beacon/BFX23U4BUFE7PKBKQCOLXJDZH7UCXA5CNFSM6AAAAABIUZ5T36WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUBVNFNM.gif] Message ID: @.***>