Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spack_tuda
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Inghirami, Gabriele
spack_tuda
Commits
c1eb3f96
Commit
c1eb3f96
authored
8 months ago
by
Harmen Stoppels
Committed by
Harmen Stoppels
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
libc.py: detect glibc also in chinese locale (#47434)
parent
e0d24621
No related branches found
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/spack/spack/util/libc.py
+17
-5
17 additions, 5 deletions
lib/spack/spack/util/libc.py
with
17 additions
and
5 deletions
lib/spack/spack/util/libc.py
+
17
−
5
View file @
c1eb3f96
...
@@ -9,20 +9,30 @@
...
@@ -9,20 +9,30 @@
import
shlex
import
shlex
import
sys
import
sys
from
subprocess
import
PIPE
,
run
from
subprocess
import
PIPE
,
run
from
typing
import
Optional
from
typing
import
Dict
,
Optional
import
spack.spec
import
spack.spec
import
spack.util.elf
import
spack.util.elf
#: Pattern to distinguish glibc from other libc implementations
GLIBC_PATTERN
=
r
"
\b(?:Free Software Foundation|Roland McGrath|Ulrich Depper)\b
"
def
_env
()
->
Dict
[
str
,
str
]:
"""
Currently only set LC_ALL=C without clearing further environment variables
"""
return
{
**
os
.
environ
,
"
LC_ALL
"
:
"
C
"
}
def
_libc_from_ldd
(
ldd
:
str
)
->
Optional
[
"
spack.spec.Spec
"
]:
def
_libc_from_ldd
(
ldd
:
str
)
->
Optional
[
"
spack.spec.Spec
"
]:
try
:
try
:
result
=
run
([
ldd
,
"
--version
"
],
stdout
=
PIPE
,
stderr
=
PIPE
,
check
=
False
)
result
=
run
([
ldd
,
"
--version
"
],
stdout
=
PIPE
,
stderr
=
PIPE
,
check
=
False
,
env
=
_env
()
)
stdout
=
result
.
stdout
.
decode
(
"
utf-8
"
)
stdout
=
result
.
stdout
.
decode
(
"
utf-8
"
)
except
Exception
:
except
Exception
:
return
None
return
None
if
not
re
.
search
(
r
"
\bFree Software Foundation\b
"
,
stdout
):
# The string "Free Software Foundation" is sometimes translated and not detected, but the names
# of the authors are typically present.
if
not
re
.
search
(
GLIBC_PATTERN
,
stdout
):
return
None
return
None
version_str
=
re
.
match
(
r
"
.+\(.+\) (.+)
"
,
stdout
)
version_str
=
re
.
match
(
r
"
.+\(.+\) (.+)
"
,
stdout
)
...
@@ -58,7 +68,9 @@ def libc_from_dynamic_linker(dynamic_linker: str) -> Optional["spack.spec.Spec"]
...
@@ -58,7 +68,9 @@ def libc_from_dynamic_linker(dynamic_linker: str) -> Optional["spack.spec.Spec"]
# Now try to figure out if glibc or musl, which is the only ones we support.
# Now try to figure out if glibc or musl, which is the only ones we support.
# In recent glibc we can simply execute the dynamic loader. In musl that's always the case.
# In recent glibc we can simply execute the dynamic loader. In musl that's always the case.
try
:
try
:
result
=
run
([
dynamic_linker
,
"
--version
"
],
stdout
=
PIPE
,
stderr
=
PIPE
,
check
=
False
)
result
=
run
(
[
dynamic_linker
,
"
--version
"
],
stdout
=
PIPE
,
stderr
=
PIPE
,
check
=
False
,
env
=
_env
()
)
stdout
=
result
.
stdout
.
decode
(
"
utf-8
"
)
stdout
=
result
.
stdout
.
decode
(
"
utf-8
"
)
stderr
=
result
.
stderr
.
decode
(
"
utf-8
"
)
stderr
=
result
.
stderr
.
decode
(
"
utf-8
"
)
except
Exception
:
except
Exception
:
...
@@ -75,7 +87,7 @@ def libc_from_dynamic_linker(dynamic_linker: str) -> Optional["spack.spec.Spec"]
...
@@ -75,7 +87,7 @@ def libc_from_dynamic_linker(dynamic_linker: str) -> Optional["spack.spec.Spec"]
return
spec
return
spec
except
Exception
:
except
Exception
:
return
None
return
None
elif
re
.
search
(
r
"
\bFree Software Foundation\b
"
,
stdout
):
elif
re
.
search
(
GLIBC_PATTERN
,
stdout
):
# output is like "ld.so (...) stable release version 2.33."
# output is like "ld.so (...) stable release version 2.33."
match
=
re
.
search
(
r
"
version (\d+\.\d+(?:\.\d+)?)
"
,
stdout
)
match
=
re
.
search
(
r
"
version (\d+\.\d+(?:\.\d+)?)
"
,
stdout
)
if
not
match
:
if
not
match
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment