47
47
# XXX : we want AnyPlatform to look like `x86_64-linux-musl` in the build environment.
48
48
aatriplet (p:: AnyPlatform ) = aatriplet (default_host_platform)
49
49
50
+ function ld_library_path (target:: AbstractPlatform ,
51
+ host:: AbstractPlatform ,
52
+ prefix:: String = " " ,
53
+ host_libdir:: String = " " ;
54
+ csl_paths:: Bool = true )
55
+ # Helper for generating the library include path for a target. MacOS, as usual,
56
+ # puts things in slightly different place.
57
+ function target_lib_dir (p:: AbstractPlatform )
58
+ t = aatriplet (p)
59
+ if Sys. isapple (p)
60
+ return " /opt/$(t) /$(t) /lib:/opt/$(t) /lib"
61
+ else
62
+ return " /opt/$(t) /$(t) /lib64:/opt/$(t) /$(t) /lib"
63
+ end
64
+ end
65
+
66
+ # Let's start
67
+ paths = String[]
68
+
69
+ # If requested, start with our CSL libraries for target/host, but only for architectures
70
+ # that can natively run within this environment
71
+ if csl_paths
72
+ # Ok, this is incredibly finicky. If the target has the same architecture as the
73
+ # host, we should have the host first then the target, otherwise we need to have
74
+ # target first.
75
+ platforms = arch (target) == arch (host) ? (host, target) : (target, host)
76
+ append! (paths,
77
+ unique (" /usr/lib/csl-$(libc (p)) -$(arch (p)) " for p in platforms if Sys. islinux (p) && proc_family (p) == " intel" ),
78
+ )
79
+ end
80
+
81
+ push! (paths,
82
+ # Then add default system paths
83
+ " /usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib" ,
84
+ # Add our loader directories
85
+ " /lib64:/lib" ,
86
+ )
87
+
88
+ if ! isempty (host_libdir)
89
+ push! (paths,
90
+ # Libdir of the host platform, to run programs in `HostBuildDependency`
91
+ host_libdir,
92
+ )
93
+ end
94
+
95
+ push! (paths,
96
+ # Add our target/host-specific library directories for compiler support libraries
97
+ target_lib_dir (host),
98
+ target_lib_dir (target),
99
+ )
100
+
101
+ # Finally, add dependencies in the prefix
102
+ if ! isempty (prefix)
103
+ push! (paths,
104
+ " $(prefix) /lib64:$(prefix) /lib" ,
105
+ )
106
+ end
107
+
108
+ return join (paths, " :" )
109
+ end
110
+
50
111
"""
51
112
generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::AbstractString,
52
113
host_platform::AbstractPlatform = $(repr (default_host_platform)) ,
@@ -396,7 +457,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
396
457
allow_ccache,
397
458
no_soft_float= arch (p) in (" armv6l" , " armv7l" ),
398
459
# Override `LD_LIBRARY_PATH` to avoid external settings mess it up.
399
- env= Dict (" LD_LIBRARY_PATH" => " " ),
460
+ env= Dict (" LD_LIBRARY_PATH" => ld_library_path (platform, host_platform; csl_paths = false ) ),
400
461
)
401
462
end
402
463
@@ -409,7 +470,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
409
470
link_only_flags= clang_link_flags! (p),
410
471
no_soft_float= arch (p) in (" armv6l" , " armv7l" ),
411
472
# Override `LD_LIBRARY_PATH` to avoid external settings mess it up.
412
- env= Dict (" LD_LIBRARY_PATH" => " " ),
473
+ env= Dict (" LD_LIBRARY_PATH" => ld_library_path (platform, host_platform; csl_paths = false ) ),
413
474
)
414
475
end
415
476
@@ -873,17 +934,6 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
873
934
return mapping
874
935
end
875
936
876
- # Helper for generating the library include path for a target. MacOS, as usual,
877
- # puts things in slightly different place.
878
- function target_lib_dir (p:: AbstractPlatform )
879
- t = aatriplet (p)
880
- if Sys. isapple (p)
881
- return " /opt/$(t) /$(t) /lib:/opt/$(t) /lib"
882
- else
883
- return " /opt/$(t) /$(t) /lib64:/opt/$(t) /$(t) /lib"
884
- end
885
- end
886
-
887
937
function GOARM (p:: AbstractPlatform )
888
938
# See https://github.com/golang/go/wiki/GoArm#supported-architectures
889
939
if arch (p) == " armv6l"
@@ -895,16 +945,6 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
895
945
end
896
946
end
897
947
898
- # Generate CSL paths for target and host platforms, but only if these are platforms for
899
- # which we can run executables, i.e. Intel penguins.
900
- function csl_paths (target:: AbstractPlatform , host:: AbstractPlatform )
901
- # Ok, this is incredibly finicky: if the target has the same architecture as the
902
- # host, we should have the host first then the target, otherwise we need to have
903
- # target first.
904
- platforms = arch (target) == arch (host) ? (host, target) : (target, host)
905
- return join (unique (" /usr/lib/csl-$(libc (p)) -$(arch (p)) " for p in platforms if Sys. islinux (p) && proc_family (p) == " intel" ), " :" )
906
- end
907
-
908
948
merge! (mapping, Dict (
909
949
" PATH" => join ((
910
950
# First things first, our compiler wrappers trump all
@@ -922,21 +962,7 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
922
962
mapping[" bindir" ],
923
963
), " :" ),
924
964
925
- " LD_LIBRARY_PATH" => join ((
926
- # Start with our CSL libraries for target/host, but only for architectures that can natively run within this environment
927
- csl_paths (platform, host_platform),
928
- # Then add default system paths
929
- " /usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib" ,
930
- # Add our loader directories
931
- " /lib64:/lib" ,
932
- # Libdir of the host platform, to run programs in `HostBuildDependency`
933
- " $(host_libdir) " ,
934
- # Add our target/host-specific library directories for compiler support libraries
935
- target_lib_dir (host_platform),
936
- target_lib_dir (platform),
937
- # Finally, dependencies
938
- " $(prefix) /lib64:$(prefix) /lib" ,
939
- ), " :" ),
965
+ " LD_LIBRARY_PATH" => ld_library_path (platform, host_platform, prefix, host_libdir),
940
966
941
967
# Default mappings for some tools
942
968
" CC" => " cc" ,
0 commit comments