gem5-dev@gem5.org

The gem5 Developer List

View all threads

[XS] Change in gem5/gem5[develop]: scons: fix build failed caused by Non-ASCII directory path

LW
Luming Wang (Gerrit)
Tue, May 23, 2023 7:25 AM

Luming Wang has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/70818?usp=email )

Change subject: scons: fix build failed caused by Non-ASCII directory path
......................................................................

scons: fix build failed caused by Non-ASCII directory path

This patch addresses the issue of gem5 failing to build when
the build directory path contains non-ASCII characters.
The previous patches[1] that attempted to fix this issue
became ineffective after the upgrade of Python and pybind11
to new versions. This new patch manually sets the locale in
marshal.py based on the LC_CTYPE environment variable,
providing a comprehensive solution that works with Non-ASCII
build directory paths.

[1] https://gem5-review.googlesource.com/c/public/gem5/+/58369

Change-Id: I3ad28b6ee52fd347d2fe71f279baab629e88d12c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70818
Tested-by: kokoro noreply+kokoro@google.com
Reviewed-by: Bobby Bruce bbruce@ucdavis.edu
Maintainer: Bobby Bruce bbruce@ucdavis.edu

M build_tools/marshal.py
M site_scons/gem5_scons/defaults.py
2 files changed, 7 insertions(+), 0 deletions(-)

Approvals:
Bobby Bruce: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass

diff --git a/build_tools/marshal.py b/build_tools/marshal.py
index 18afe2c..4a1522f 100644
--- a/build_tools/marshal.py
+++ b/build_tools/marshal.py
@@ -48,6 +48,7 @@
this script, and to read in and execute the marshalled code later.
"""

+import locale
import marshal
import sys
import zlib
@@ -65,6 +66,11 @@
print(f"Usage: {sys.argv[0]} CPP PY MODPATH ABSPATH", file=sys.stderr)
sys.exit(1)

+# Set the Python's locale settings manually based on the LC_CTYPE
+# environment variable
+if "LC_CTYPE" in os.environ:

  • locale.setlocale(locale.LC_CTYPE, os.environ["LC_CTYPE"])

  • _, cpp, python, modpath, abspath = sys.argv

    with open(python, "r") as f:
    diff --git a/site_scons/gem5_scons/defaults.py
    b/site_scons/gem5_scons/defaults.py
    index a07b7ff..996cfd4 100644
    --- a/site_scons/gem5_scons/defaults.py
    +++ b/site_scons/gem5_scons/defaults.py
    @@ -66,6 +66,7 @@
    "GEM5PY_LINKFLAGS_EXTRA",
    "LINKFLAGS_EXTRA",
    "LANG",

  •        "LC_CTYPE",
        ]
    )
    

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/70818?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I3ad28b6ee52fd347d2fe71f279baab629e88d12c
Gerrit-Change-Number: 70818
Gerrit-PatchSet: 4
Gerrit-Owner: Luming Wang wlm199558@126.com
Gerrit-Reviewer: Bobby Bruce bbruce@ucdavis.edu
Gerrit-Reviewer: Gabe Black gabe.black@gmail.com
Gerrit-Reviewer: Jason Lowe-Power power.jg@gmail.com
Gerrit-Reviewer: Luming Wang wlm199558@126.com
Gerrit-Reviewer: kokoro noreply+kokoro@google.com

Luming Wang has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/70818?usp=email ) Change subject: scons: fix build failed caused by Non-ASCII directory path ...................................................................... scons: fix build failed caused by Non-ASCII directory path This patch addresses the issue of gem5 failing to build when the build directory path contains non-ASCII characters. The previous patches[1] that attempted to fix this issue became ineffective after the upgrade of Python and pybind11 to new versions. This new patch manually sets the locale in marshal.py based on the `LC_CTYPE` environment variable, providing a comprehensive solution that works with Non-ASCII build directory paths. [1] https://gem5-review.googlesource.com/c/public/gem5/+/58369 Change-Id: I3ad28b6ee52fd347d2fe71f279baab629e88d12c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70818 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu> Maintainer: Bobby Bruce <bbruce@ucdavis.edu> --- M build_tools/marshal.py M site_scons/gem5_scons/defaults.py 2 files changed, 7 insertions(+), 0 deletions(-) Approvals: Bobby Bruce: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/build_tools/marshal.py b/build_tools/marshal.py index 18afe2c..4a1522f 100644 --- a/build_tools/marshal.py +++ b/build_tools/marshal.py @@ -48,6 +48,7 @@ this script, and to read in and execute the marshalled code later. """ +import locale import marshal import sys import zlib @@ -65,6 +66,11 @@ print(f"Usage: {sys.argv[0]} CPP PY MODPATH ABSPATH", file=sys.stderr) sys.exit(1) +# Set the Python's locale settings manually based on the `LC_CTYPE` +# environment variable +if "LC_CTYPE" in os.environ: + locale.setlocale(locale.LC_CTYPE, os.environ["LC_CTYPE"]) + _, cpp, python, modpath, abspath = sys.argv with open(python, "r") as f: diff --git a/site_scons/gem5_scons/defaults.py b/site_scons/gem5_scons/defaults.py index a07b7ff..996cfd4 100644 --- a/site_scons/gem5_scons/defaults.py +++ b/site_scons/gem5_scons/defaults.py @@ -66,6 +66,7 @@ "GEM5PY_LINKFLAGS_EXTRA", "LINKFLAGS_EXTRA", "LANG", + "LC_CTYPE", ] ) -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/70818?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: public/gem5 Gerrit-Branch: develop Gerrit-Change-Id: I3ad28b6ee52fd347d2fe71f279baab629e88d12c Gerrit-Change-Number: 70818 Gerrit-PatchSet: 4 Gerrit-Owner: Luming Wang <wlm199558@126.com> Gerrit-Reviewer: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-Reviewer: Gabe Black <gabe.black@gmail.com> Gerrit-Reviewer: Jason Lowe-Power <power.jg@gmail.com> Gerrit-Reviewer: Luming Wang <wlm199558@126.com> Gerrit-Reviewer: kokoro <noreply+kokoro@google.com>