diff --git a/.gitmodules b/.gitmodules
index b8de722..b187d91 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -6,3 +6,6 @@
 	path = src/submodule_packages/binutils-gdb
 	url = git@github.com:guyush1/binutils-gdb.git
 	branch = gdb-static
+[submodule "src/submodule_packages/pygments"]
+	path = src/submodule_packages/pygments
+	url = git@github.com:pygments/pygments.git
diff --git a/src/compilation/build.sh b/src/compilation/build.sh
index bc6d903..10dbf94 100755
--- a/src/compilation/build.sh
+++ b/src/compilation/build.sh
@@ -220,6 +220,8 @@ function build_python() {
     # Parameters:
     # $1: python package directory
     # $2: target architecture
+    # $3: gdb's python module directory parent
+    # $4: pygment's toplevel source dir.
     #
     # Echoes:
     # The python build directory
@@ -229,6 +231,8 @@ function build_python() {
     # 1: failure
     local python_dir="$1"
     local target_arch="$2"
+    local gdb_python_parent="$3"
+    local pygments_source_dir="$4"
     local python_lib_dir="$(realpath "$python_dir/build-$target_arch")"
 
     echo "$python_lib_dir"
@@ -257,6 +261,17 @@ function build_python() {
         --disable-ipv6 \
         --disable-shared
 
+    # Extract the regular standard library modules that are to be frozen and include the gdb and pygments custom libraries.
+    export EXTRA_FROZEN_MODULES="$(printf "%s" "$(< ${script_dir}/frozen_python_modules.txt)" | tr $'\n' ";")"
+    export EXTRA_FROZEN_MODULES="${EXTRA_FROZEN_MODULES};<gdb.**.*>: gdb = ${gdb_python_parent};<pygments.**.*>: pygments = ${pygments_source_dir}"
+    >&2 echo "Frozen Modules: ${EXTRA_FROZEN_MODULES}"
+
+    # Regenerate frozen modules with gdb env varaible. Do it after the configure because we need
+    # the `regen-frozen` makefile.
+    >&2 python3.12 ../Tools/build/freeze_modules.py
+    >&2 make regen-frozen
+
+    # Build python after configuring the project and regnerating frozen files.
     >&2 make -j $(nproc)
     if [[ $? -ne 0 ]]; then
         return 1
@@ -518,7 +533,9 @@ function build_gdb_with_dependencies() {
     set_ncurses_link_variables "$ncursesw_build_dir"
 
     if [[ "$with_python" == "yes" ]]; then
-        build_python "$packages_dir/cpython-static" "$target_arch"
+        local gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/"
+        local pygments_source_dir="$packages_dir/pygments/"
+        local python_build_dir="$(build_python "$packages_dir/cpython-static" "$target_arch" "$gdb_python_dir" "$pygments_source_dir")"
         if [[ $? -ne 0 ]]; then
             return 1
         fi
diff --git a/src/compilation/frozen_python_modules.txt b/src/compilation/frozen_python_modules.txt
new file mode 100644
index 0000000..8038f15
--- /dev/null
+++ b/src/compilation/frozen_python_modules.txt
@@ -0,0 +1,150 @@
+abc
+_aix_support
+antigravity
+argparse
+ast
+base64
+bdb
+bisect
+calendar
+cmd
+codecs
+codeop
+code
+<collections.**.*>
+_collections_abc
+colorsys
+_compat_pickle
+compileall
+_compression
+<concurrent.**.*>
+configparser
+contextlib
+contextvars
+copy
+copyreg
+cProfile
+csv
+dataclasses
+datetime
+<dbm.**.*>
+decimal
+difflib
+dis
+<encodings.**.*>
+<ensurepip.**.*>
+enum
+filecmp
+fileinput
+fnmatch
+fractions
+ftplib
+functools
+__future__
+genericpath
+getopt
+getpass
+gettext
+glob
+graphlib
+gzip
+hashlib
+heapq
+hmac
+imaplib
+<importlib.**.*>
+inspect
+io
+ipaddress
+<json.**.*>
+keyword
+linecache
+locale
+<logging.**.*>
+lzma
+_markupbase
+mimetypes
+modulefinder
+<multiprocessing.**.*>
+netrc
+ntpath
+nturl2path
+numbers
+opcode
+operator
+optparse
+os
+_osx_support
+pathlib
+pdb
+<__phello__.**.*>
+pickle
+pickletools
+pkgutil
+platform
+plistlib
+poplib
+posixpath
+pprint
+profile
+pstats
+pty
+_py_abc
+pyclbr
+py_compile
+_pydatetime
+_pydecimal
+_pyio
+_pylong
+queue
+quopri
+random
+<re.**.*>
+reprlib
+rlcompleter
+sched
+selectors
+shelve
+shlex
+shutil
+signal
+smtplib
+socket
+socketserver
+statistics
+stat
+stringprep
+string
+_strptime
+struct
+subprocess
+symtable
+sysconfig
+tabnanny
+tempfile
+textwrap
+this
+_threading_local
+threading
+timeit
+tokenize
+token
+<tomllib.**.*>
+traceback
+tracemalloc
+trace
+tty
+types
+typing
+uuid
+warnings
+wave
+weakref
+_weakrefset
+webbrowser
+<wsgiref.**.*>
+zipapp
+<zipfile.**.*>
+<zoneinfo.**.*>
+<email.**.*>
+<urllib.**.*>
diff --git a/src/submodule_packages/binutils-gdb b/src/submodule_packages/binutils-gdb
index f7d0fb2..34012c4 160000
--- a/src/submodule_packages/binutils-gdb
+++ b/src/submodule_packages/binutils-gdb
@@ -1 +1 @@
-Subproject commit f7d0fb2e220e565b54f9e963b9a2bee58265e454
+Subproject commit 34012c42d0a2edaad66265c76e63104d8b4cd0b6
diff --git a/src/submodule_packages/cpython-static b/src/submodule_packages/cpython-static
index 7ffd428..74ab746 160000
--- a/src/submodule_packages/cpython-static
+++ b/src/submodule_packages/cpython-static
@@ -1 +1 @@
-Subproject commit 7ffd428d5b945b3baf5d5f6f856bdeb3bc8377a9
+Subproject commit 74ab74654b867a6e1c3b2af3ccf6b7b74b0e9a9b
diff --git a/src/submodule_packages/pygments b/src/submodule_packages/pygments
new file mode 160000
index 0000000..b583de4
--- /dev/null
+++ b/src/submodule_packages/pygments
@@ -0,0 +1 @@
+Subproject commit b583de4794e94b4dc4c2da03a7c29f462482293e