Skip to content

Commit 3d4b5b3

Browse files
committed
Update README
1 parent 5b7c298 commit 3d4b5b3

File tree

1 file changed

+82
-10
lines changed

1 file changed

+82
-10
lines changed

README.md

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@ The following Cargo features are supported:
1111
* `cache` to build in a shared directory instead of `target` (see below),
1212
* `cblas` to build CBLAS (enabled by default),
1313
* `lapacke` to build LAPACKE (enabled by default),
14-
* `static` to link to OpenBLAS statically, and
14+
* `static` to link to OpenBLAS statically,
1515
* `system` to skip building the bundled OpenBLAS.
1616

17+
Note: On Windows, OpenBLAS can not be built from source. The `system` feature is
18+
supposed to be used.
19+
20+
## Dependencies
21+
22+
If you want to build OpenBLAS from source, you need to have the following dependencies
23+
installed:
24+
25+
* HOSTCC compiler (e.g., `gcc`, `clang`, or `icc`),
26+
* `make`,
27+
* CC compiler of the target architecture (e.g., `aarch64-linux-gnu-gcc` for `aarch64`),
28+
* Fortran compiler of the target architecture(e.g., `gfortran`, `flang`, or `ifort`),
29+
if there is no Fortran compiler detected, the flag `NOFORTRAN` should be set to `1`
30+
and `OpenBLAS` will only compile BLAS and f2c-converted LAPACK. For more information,
31+
please refer to the [Use f2c translations of LAPACK when no Fortran compiler is available][f2c-translations].
32+
1733
## Caching
1834

1935
The `cache` feature allows the OpenBLAS build products to be reused between
@@ -45,31 +61,84 @@ To link OpenBLAS statically, install `openblas` for the `x64-windows-static-md`
4561
vcpkg install openblas --triplet x64-windows-static-md
4662
```
4763

48-
To link OpenBLAS and C Runtime (CRT) statically, install `openblas` for the `x64-windows-static` triplet:
64+
To link OpenBLAS and C Runtime (CRT) statically, install `openblas` for the
65+
`x64-windows-static` triplet:
4966

5067
```sh
5168
vcpkg install openblas --triplet x64-windows-static
5269
```
5370

5471
and build with `+crt-static` option
5572

56-
```
73+
```sh
5774
RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-pc-windows-msvc
5875
```
5976

60-
Please see the ["Static and dynamic C runtimes" in The Rust reference](https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes) for detail.
77+
Please see the ["Static and dynamic C runtimes" in The Rust reference][crt-static] for detail.
78+
79+
## ENV variables
6180

62-
## Cross Compilation
81+
### Proxy
82+
83+
The `openblas-src` crate will detect and use proxy settings from your environment
84+
variables, such as `http_proxy` and `https_proxy` to download necessary dependencies.
85+
86+
### Build System through OpenBLAS
87+
88+
According to the [OpenbLAS build system], the variables used by OpenBLAS could be
89+
passed through environment, such as `DYNAMIC_LIST`, `NUM_THREADS`.
90+
91+
**HOWEVER**, for some of the variables, the `openblas-src` crate rename them to
92+
others to avoid conflicts with the existing envs. The following is the list of
93+
the variables that are renamed:
94+
95+
| OpenBLAS variable | openblas-src variable |
96+
| ----------------- | --------------------- |
97+
| TARGET | OPENBLAS_TARGET |
98+
| CC | OPENBLAS_CC |
99+
| FC | OPENBLAS_FC |
100+
| HOSTCC | OPENBLAS_HOSTCC |
101+
| RANLIB | OPENBLAS_RANLIB |
102+
103+
## Cross-compile
63104

64105
Apart from providing the `--target` option to `cargo build`, one also has to
65106
specify the [cross-compilation variables of OpenBLAS][openblas-cross-compile].
66107
They can be set as environment variables for `cargo build` using the `OPENBLAS_`
67108
prefix as follows: `OPENBLAS_CC`, `OPENBLAS_FC`, `OPENBLAS_HOSTCC`, and
68109
`OPENBLAS_TARGET`.
69110

70-
## Proxy issues
71-
72-
The `openblas-src` crate will detect and use proxy settings from your environment variables, such as `http_proxy` and `https_proxy` to download necessary dependencies.
111+
If you do not set these variables, the `openblas-build` will try to detect them.
112+
113+
For `OPENBLAS_TARGET`, the basic target that corresponds to the arch of `--target`
114+
will be used.
115+
116+
| Rust target | OpenBLAS target |
117+
| ----------- | --------------- |
118+
| aarch64 | ARMV8 |
119+
| arm | ARMV6 |
120+
| armv5te | ARMV5 |
121+
| armv6 | ARMV6 |
122+
| armv7 | ARMV7 |
123+
| loongarch64 | LOONGSONGENERIC |
124+
| mips64 | MIPS64_GENERIC |
125+
| mips64el | MIPS64_GENERIC |
126+
| riscv64 | RISCV64_GENERIC |
127+
| csky | CK860FV |
128+
| sparc | SPARCV7 |
129+
130+
For `OPENBLAS_CC` and `OPENBLAS_HOSTCC`, the `cc` crate will be used to detect
131+
the compiler. Please refer to the [cc documentation](https://docs.rs/cc/latest/cc/)
132+
for more information.
133+
134+
For `OPENBLAS_FC`, `openblas-build` will try to detect the compiler through the
135+
`OPENBLAS_CC` set above. It will replace the `gcc` with `gfortran`, `clang` with
136+
`flang`, and `icc` with `ifort` and then test if the Fortran compiler exists.
137+
138+
Note: If there is no Fortran compiler detected, the build flag `NOFORTRAN` will
139+
be set to `1` and `OpenBLAS` will only compile BLAS and f2c-converted LAPACK.
140+
For more information, please refer to the
141+
[Use f2c translations of LAPACK when no Fortran compiler is available][f2c-translations].
73142

74143
## Contribution
75144

@@ -80,9 +149,12 @@ will be licensed according to the terms given in [LICENSE.md](LICENSE.md).
80149
[architecture]: https://blas-lapack-rs.github.io/architecture
81150
[blas]: https://en.wikipedia.org/wiki/BLAS
82151
[lapack]: https://en.wikipedia.org/wiki/LAPACK
83-
[openblas]: http://www.openblas.net/
84-
[openblas-cross-compile]: https://github.com/xianyi/OpenBLAS#cross-compile
152+
[OpenBLAS]: http://www.openmathlib.org/OpenBLAS/
153+
[openblas-cross-compile]: http://www.openmathlib.org/OpenBLAS/docs/user_manual/#cross-compile
154+
[OpenbLAS build system]: http://www.openmathlib.org/OpenBLAS/docs/build_system/
85155
[vcpkg]: https://github.com/Microsoft/vcpkg
156+
[f2c-translations]: https://github.com/OpenMathLib/OpenBLAS/pull/3539
157+
[crt-static]: https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes
86158

87159
[build-img]: https://github.com/blas-lapack-rs/openblas-src/workflows/Rust/badge.svg
88160
[build-url]: https://github.com/blas-lapack-rs/openblas-src/actions?query=workflow%3ARust

0 commit comments

Comments
 (0)