Linux

  • 需要 GCC 版本 4.7 或更高版本才能构建 Julia。
  • 要使用不在系统库搜索路径中的外部共享库,请在 Make.user 中设置 USE_SYSTEM_XXX=1LDFLAGS=-Wl,-rpath,/path/to/dir/contains/libXXX.so
  • 除了设置 LDFLAGS,将库目录放入环境变量 LD_LIBRARY_PATH(在编译和运行时)也可以。
  • USE_SYSTEM_* 标志应谨慎使用。这些标志仅用于故障排除、移植和打包,包维护者与 Julia 开发者密切合作,以确保 Julia 正确构建。生产用例应使用官方提供的二进制文件。由于使用这些标志而产生的问题通常不会被接受。
  • 另请参见 external dependencies

Architecture Customization

Julia 可以通过在 Make.user 文件中配置 ARCH Makefile 变量来为非通用架构构建。有关其他自定义选项,例如 MARCHJULIA_CPU_TARGET,请参见 Make.inc 的相关部分。

例如,要为 Pentium 4 构建,设置 MARCH=pentium4 并安装必要的系统库以进行链接。在 Ubuntu 上,这些库可能包括 lib32gfortran-6-dev、lib32gcc1 和 lib32stdc++6 等。

您还可以在 Make.user 中设置 MARCH=native,以获得针对当前机器 CPU 的最大性能构建。

Linux Build Troubleshooting

ProblemPossible Solution
OpenBLAS build failureSet one of the following build options in Make.user and build again: <ul><li> OPENBLAS_TARGET_ARCH=BARCELONA (AMD CPUs) or OPENBLAS_TARGET_ARCH=NEHALEM (Intel CPUs)<ul>Set OPENBLAS_DYNAMIC_ARCH = 0 to disable compiling multiple architectures in a single binary.</ul></li><li> OPENBLAS_NO_AVX2 = 1 disables AVX2 instructions, allowing OpenBLAS to compile with OPENBLAS_DYNAMIC_ARCH = 1 using old versions of binutils </li><li> USE_SYSTEM_BLAS=1 uses the system provided libblas <ul><li>Set LIBBLAS=-lopenblas and LIBBLASNAME=libopenblas to force the use of the system provided OpenBLAS when multiple BLAS versions are installed. </li></ul></li></ul><p> If you get an error that looks like ../kernel/x86_64/dgemm_kernel_4x4_haswell.S:1709: Error: no such instruction: `vpermpd $ 0xb1,%ymm0,%ymm0', then you need to set OPENBLAS_DYNAMIC_ARCH = 0 or OPENBLAS_NO_AVX2 = 1, or you need a newer version of binutils (2.18 or newer). (Issue #7653)</p><p> If the linker cannot find gfortran and you get an error like julia /usr/bin/x86_64-linux-gnu-ld: cannot find -lgfortran, check the path with gfortran -print-file-name=libgfortran.so and use the output to export something similar to this: export LDFLAGS=-L/usr/lib/gcc/x86_64-linux-gnu/8/. See Issue #6150.</p>
Illegal Instruction errorCheck if your CPU supports AVX while your OS does not (e.g. through virtualization, as described in this issue).