scons: Fix gem5 Python3.11 build.
The code generation in gem5's build system requires the use of Regular Expression flags when defining the regular expressions used for tokenization. However, the Python Lex-Yacc (PLY) [1] library used by gem5 does not allow the user sufficient control of the flags for RE compilation. Previously, gem5 used inline RE flags to control RE compilation. However, from Python 3.11, inline RE flags must be at the start of the RE string. Because PLY wraps the user supplied RE strings before compilation, there is no way for the user to supply a RE string with the inline flag at the start. This makes gem5 incompatible with Python 3.11 when using PLY. This change modifies gem5's build files to patch `re.compile` with a wrapped version that can handle embedded flags anywhere in the RE string, for all current versions of Python. The patched version re-formats the user supplied RE string to convert inline RE flags to explicit RE flags. This patch is intended as a temporary stop-gap until PLY can be fixed upstream. See the gem5 Issue Tracker [2] for more details. [1] https://github.com/dabeaz/ply [2] https://gem5.atlassian.net/browse/GEM5-1321 Change-Id: I3ab371f2e5cf267c0a89caaf8a2bacfed78545ef Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70237 Maintainer: Bobby Bruce <bbruce@ucdavis.edu> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu> Reviewed-by: Boris Shingarov <shingarov@labware.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2013, 2015-2020 ARM Limited
|
||||
# Copyright (c) 2013, 2015-2020, 2023 ARM Limited
|
||||
# All rights reserved.
|
||||
#
|
||||
# The license below extends only to copyright in the software and shall
|
||||
@@ -171,6 +171,10 @@ SetOption('warn', 'no-duplicate-environment')
|
||||
|
||||
Export('MakeAction')
|
||||
|
||||
# Patch re.compile to support inline flags anywhere within a RE
|
||||
# string. Required to use PLY with Python 3.11+.
|
||||
gem5_scons.patch_re_compile_for_inline_flags()
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Set up the main build environment.
|
||||
|
||||
Reference in New Issue
Block a user