Skip to content

Commit 8d7b16f

Browse files
expand JULIA_CPU_TARGET docs
1 parent ff33305 commit 8d7b16f

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

doc/src/devdocs/pkgimg.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,22 @@ Dynamic libraries on macOS need to link against `-lSystem`. On recent macOS vers
3333
To that effect we link with `-undefined dynamic_lookup`.
3434

3535
## [Package images optimized for multiple microarchitectures](@id pkgimgs-multi-versioning)
36-
Similar to [multi-versioning](@ref sysimg-multi-versioning) for system images, package images support multi-versioning. If you are in a heterogeneous environment, with a unified cache,
37-
you can set the environment variable `JULIA_CPU_TARGET=generic` to multi-version the object caches.
36+
37+
Similar to [multi-versioning](@ref sysimg-multi-versioning) for system images, package images support multi-versioning. This allows creating package caches that can run efficiently on different CPU architectures within the same environment.
38+
39+
### Usage and constraints
40+
41+
Package images can only target the same or more specific CPU features than their base system image. This constraint ensures compatibility and prevents runtime errors.
42+
43+
To enable multi-versioning for package images, set the [`JULIA_CPU_TARGET`](@ref JULIA_CPU_TARGET) environment variable when building packages:
44+
45+
```bash
46+
# Create multi-versioned package images for generic and optimized targets
47+
export JULIA_CPU_TARGET="generic;haswell"
48+
49+
# For heterogeneous environments, use generic to ensure broad compatibility
50+
export JULIA_CPU_TARGET="generic"
51+
```
3852

3953
## Flags that impact package image creation and selection
4054

doc/src/manual/environment-variables.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,22 @@ A `generic` or empty CPU name means the basic required feature set of the target
489489
which is at least the architecture the C/C++ runtime is compiled with. Each string
490490
is interpreted by LLVM.
491491

492+
#### Examples of valid `JULIA_CPU_TARGET` values
493+
494+
- `generic` - produces portable code for the basic ISA
495+
- `haswell` - optimizes for Intel Haswell microarchitecture
496+
- `generic;haswell` - creates multi-versioned images with both generic and optimized variants
497+
- `x86-64-v3;x86-64-v4` - targets x86-64 microarchitecture levels v3 and v4
498+
499+
#### Package image compatibility constraints
500+
501+
**Important:** Package images can only target the same or more specific CPU features than
502+
their base system image. If your system image was built with `JULIA_CPU_TARGET=generic`,
503+
package images can use any target. However, if your system image targets a specific CPU
504+
(e.g., `haswell`), package images cannot target a less capable CPU.
505+
492506
A few special features are supported:
507+
493508
1. `clone_all`
494509

495510
This forces the target to have all functions in sysimg cloned.

0 commit comments

Comments
 (0)