We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[uTVM] Use an alternative CRC Library
The 3rdparty crc library introduced in https://github.com/apache/incubator-tvm/pull/6334 has a license problem.


We will need to replace it with a new impl or an alternative library


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `python/tvm/micro/build.py`
Content:
```
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements.  See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership.  The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License.  You may obtain a copy of the License at
8 #
9 #   http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied.  See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17 
18 """Defines top-level glue functions for building microTVM artifacts."""
19 
20 import copy
21 import logging
22 import os
23 import re
24 from tvm.contrib import util
25 
26 
27 _LOG = logging.getLogger(__name__)
28 
29 
30 class Workspace:
31     """Defines helper functions for manipulating temporary compilation workspaces."""
32 
33     def __init__(self, root=None, debug=False):
34         if debug or root is not None:
35             with util.TempDirectory.set_keep_for_debug():
36                 self.tempdir = util.tempdir(custom_path=root)
37                 _LOG.info("Created debug mode workspace at: %s", self.tempdir.temp_dir)
38         else:
39             self.tempdir = util.tempdir()
40 
41     def relpath(self, path):
42         return self.tempdir.relpath(path)
43 
44     def listdir(self):
45         return self.tempdir.listdir()
46 
47     @property
48     def path(self):
49         return self.tempdir.temp_dir
50 
51 
52 # Required C runtime libraries, in link order.
53 CRT_RUNTIME_LIB_NAMES = ["utvm_rpc_server", "utvm_rpc_common", "common"]
54 
55 
56 TVM_ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
57 
58 
59 CRT_ROOT_DIR = os.path.join(TVM_ROOT_DIR, "src", "runtime", "crt")
60 
61 
62 RUNTIME_LIB_SRC_DIRS = [os.path.join(CRT_ROOT_DIR, n) for n in CRT_RUNTIME_LIB_NAMES] + [
63     os.path.join(
64         TVM_ROOT_DIR,
65         "3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/" "libraries/crc16",
66     )
67 ]
68 
69 
70 RUNTIME_SRC_REGEX = re.compile(r"^.*\.cc?$", re.IGNORECASE)
71 
72 
73 _CRT_DEFAULT_OPTIONS = {
74     "ccflags": ["-std=c++11"],
75     "ldflags": ["-std=gnu++14"],
76     "include_dirs": [
77         f"{TVM_ROOT_DIR}/include",
78         f"{TVM_ROOT_DIR}/3rdparty/dlpack/include",
79         f"{TVM_ROOT_DIR}/3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/"
80         "TARGET_SDK_11/libraries/crc16/",
81         f"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include",
82         f"{CRT_ROOT_DIR}/include",
83     ],
84     "profile": {"common": ["-Wno-unused-variable"]},
85 }
86 
87 
88 def default_options(target_include_dir):
89     """Return default opts passed to Compile commands."""
90     bin_opts = copy.deepcopy(_CRT_DEFAULT_OPTIONS)
91     bin_opts["include_dirs"].append(target_include_dir)
92     lib_opts = copy.deepcopy(bin_opts)
93     lib_opts["profile"]["common"].append("-Werror")
94     lib_opts["cflags"] = ["-Wno-error=incompatible-pointer-types"]
95     return {"bin_opts": bin_opts, "lib_opts": lib_opts}
96 
97 
98 def build_static_runtime(workspace, compiler, module, lib_opts=None, bin_opts=None):
99     """Build the on-device runtime, statically linking the given modules.
100 
101     Parameters
102     ----------
103     compiler : tvm.micro.Compiler
104         Compiler instance used to build the runtime.
105 
106     module : IRModule
107         Module to statically link.
108 
109     lib_opts : dict
110         Extra kwargs passed to library(),
111 
112     bin_opts : dict
113         Extra kwargs passed to binary(),
114 
115     Returns
116     -------
117     MicroBinary :
118         The compiled runtime.
119     """
120     lib_opts = _CRT_DEFAULT_OPTIONS if lib_opts is None else lib_opts
121     bin_opts = _CRT_DEFAULT_OPTIONS if bin_opts is None else bin_opts
122 
123     mod_build_dir = workspace.relpath(os.path.join("build", "module"))
124     os.makedirs(mod_build_dir)
125     mod_src_dir = workspace.relpath(os.path.join("src", "module"))
126     os.makedirs(mod_src_dir)
127     mod_src_path = os.path.join(mod_src_dir, "module.c")
128     module.save(mod_src_path, "cc")
129 
130     libs = []
131     for lib_src_dir in RUNTIME_LIB_SRC_DIRS:
132         lib_name = os.path.basename(lib_src_dir)
133         lib_build_dir = workspace.relpath(f"build/{lib_name}")
134         os.makedirs(lib_build_dir)
135 
136         lib_srcs = []
137         for p in os.listdir(lib_src_dir):
138             if RUNTIME_SRC_REGEX.match(p):
139                 lib_srcs.append(os.path.join(lib_src_dir, p))
140 
141         libs.append(compiler.library(lib_build_dir, lib_srcs, lib_opts))
142 
143     libs.append(compiler.library(mod_build_dir, [mod_src_path], lib_opts))
144 
145     runtime_build_dir = workspace.relpath(f"build/runtime")
146     os.makedirs(runtime_build_dir)
147     return compiler.binary(runtime_build_dir, libs, bin_opts)
148
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/python/tvm/micro/build.py b/python/tvm/micro/build.py
--- a/python/tvm/micro/build.py
+++ b/python/tvm/micro/build.py
@@ -60,10 +60,7 @@
 
 
 RUNTIME_LIB_SRC_DIRS = [os.path.join(CRT_ROOT_DIR, n) for n in CRT_RUNTIME_LIB_NAMES] + [
-    os.path.join(
-        TVM_ROOT_DIR,
-        "3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/" "libraries/crc16",
-    )
+    os.path.join(TVM_ROOT_DIR, "3rdparty/libcrc/src")
 ]
 
 
@@ -76,8 +73,7 @@
     "include_dirs": [
         f"{TVM_ROOT_DIR}/include",
         f"{TVM_ROOT_DIR}/3rdparty/dlpack/include",
-        f"{TVM_ROOT_DIR}/3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/"
-        "TARGET_SDK_11/libraries/crc16/",
+        f"{TVM_ROOT_DIR}/3rdparty/libcrc/include",
         f"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include",
         f"{CRT_ROOT_DIR}/include",
     ],

{"golden_diff": "diff --git a/python/tvm/micro/build.py b/python/tvm/micro/build.py\n--- a/python/tvm/micro/build.py\n+++ b/python/tvm/micro/build.py\n@@ -60,10 +60,7 @@\n \n \n RUNTIME_LIB_SRC_DIRS = [os.path.join(CRT_ROOT_DIR, n) for n in CRT_RUNTIME_LIB_NAMES] + [\n-    os.path.join(\n-        TVM_ROOT_DIR,\n-        \"3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/\" \"libraries/crc16\",\n-    )\n+    os.path.join(TVM_ROOT_DIR, \"3rdparty/libcrc/src\")\n ]\n \n \n@@ -76,8 +73,7 @@\n     \"include_dirs\": [\n         f\"{TVM_ROOT_DIR}/include\",\n         f\"{TVM_ROOT_DIR}/3rdparty/dlpack/include\",\n-        f\"{TVM_ROOT_DIR}/3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/\"\n-        \"TARGET_SDK_11/libraries/crc16/\",\n+        f\"{TVM_ROOT_DIR}/3rdparty/libcrc/include\",\n         f\"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include\",\n         f\"{CRT_ROOT_DIR}/include\",\n     ],\n", "issue": "[uTVM] Use an alternative CRC Library\nThe 3rdparty crc library introduced in https://github.com/apache/incubator-tvm/pull/6334 has a license problem.\r\n\r\n\r\nWe will need to replace it with a new impl or an alternative library\r\n\n", "before_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\n\"\"\"Defines top-level glue functions for building microTVM artifacts.\"\"\"\n\nimport copy\nimport logging\nimport os\nimport re\nfrom tvm.contrib import util\n\n\n_LOG = logging.getLogger(__name__)\n\n\nclass Workspace:\n    \"\"\"Defines helper functions for manipulating temporary compilation workspaces.\"\"\"\n\n    def __init__(self, root=None, debug=False):\n        if debug or root is not None:\n            with util.TempDirectory.set_keep_for_debug():\n                self.tempdir = util.tempdir(custom_path=root)\n                _LOG.info(\"Created debug mode workspace at: %s\", self.tempdir.temp_dir)\n        else:\n            self.tempdir = util.tempdir()\n\n    def relpath(self, path):\n        return self.tempdir.relpath(path)\n\n    def listdir(self):\n        return self.tempdir.listdir()\n\n    @property\n    def path(self):\n        return self.tempdir.temp_dir\n\n\n# Required C runtime libraries, in link order.\nCRT_RUNTIME_LIB_NAMES = [\"utvm_rpc_server\", \"utvm_rpc_common\", \"common\"]\n\n\nTVM_ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), \"..\", \"..\", \"..\"))\n\n\nCRT_ROOT_DIR = os.path.join(TVM_ROOT_DIR, \"src\", \"runtime\", \"crt\")\n\n\nRUNTIME_LIB_SRC_DIRS = [os.path.join(CRT_ROOT_DIR, n) for n in CRT_RUNTIME_LIB_NAMES] + [\n    os.path.join(\n        TVM_ROOT_DIR,\n        \"3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/\" \"libraries/crc16\",\n    )\n]\n\n\nRUNTIME_SRC_REGEX = re.compile(r\"^.*\\.cc?$\", re.IGNORECASE)\n\n\n_CRT_DEFAULT_OPTIONS = {\n    \"ccflags\": [\"-std=c++11\"],\n    \"ldflags\": [\"-std=gnu++14\"],\n    \"include_dirs\": [\n        f\"{TVM_ROOT_DIR}/include\",\n        f\"{TVM_ROOT_DIR}/3rdparty/dlpack/include\",\n        f\"{TVM_ROOT_DIR}/3rdparty/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/\"\n        \"TARGET_SDK_11/libraries/crc16/\",\n        f\"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include\",\n        f\"{CRT_ROOT_DIR}/include\",\n    ],\n    \"profile\": {\"common\": [\"-Wno-unused-variable\"]},\n}\n\n\ndef default_options(target_include_dir):\n    \"\"\"Return default opts passed to Compile commands.\"\"\"\n    bin_opts = copy.deepcopy(_CRT_DEFAULT_OPTIONS)\n    bin_opts[\"include_dirs\"].append(target_include_dir)\n    lib_opts = copy.deepcopy(bin_opts)\n    lib_opts[\"profile\"][\"common\"].append(\"-Werror\")\n    lib_opts[\"cflags\"] = [\"-Wno-error=incompatible-pointer-types\"]\n    return {\"bin_opts\": bin_opts, \"lib_opts\": lib_opts}\n\n\ndef build_static_runtime(workspace, compiler, module, lib_opts=None, bin_opts=None):\n    \"\"\"Build the on-device runtime, statically linking the given modules.\n\n    Parameters\n    ----------\n    compiler : tvm.micro.Compiler\n        Compiler instance used to build the runtime.\n\n    module : IRModule\n        Module to statically link.\n\n    lib_opts : dict\n        Extra kwargs passed to library(),\n\n    bin_opts : dict\n        Extra kwargs passed to binary(),\n\n    Returns\n    -------\n    MicroBinary :\n        The compiled runtime.\n    \"\"\"\n    lib_opts = _CRT_DEFAULT_OPTIONS if lib_opts is None else lib_opts\n    bin_opts = _CRT_DEFAULT_OPTIONS if bin_opts is None else bin_opts\n\n    mod_build_dir = workspace.relpath(os.path.join(\"build\", \"module\"))\n    os.makedirs(mod_build_dir)\n    mod_src_dir = workspace.relpath(os.path.join(\"src\", \"module\"))\n    os.makedirs(mod_src_dir)\n    mod_src_path = os.path.join(mod_src_dir, \"module.c\")\n    module.save(mod_src_path, \"cc\")\n\n    libs = []\n    for lib_src_dir in RUNTIME_LIB_SRC_DIRS:\n        lib_name = os.path.basename(lib_src_dir)\n        lib_build_dir = workspace.relpath(f\"build/{lib_name}\")\n        os.makedirs(lib_build_dir)\n\n        lib_srcs = []\n        for p in os.listdir(lib_src_dir):\n            if RUNTIME_SRC_REGEX.match(p):\n                lib_srcs.append(os.path.join(lib_src_dir, p))\n\n        libs.append(compiler.library(lib_build_dir, lib_srcs, lib_opts))\n\n    libs.append(compiler.library(mod_build_dir, [mod_src_path], lib_opts))\n\n    runtime_build_dir = workspace.relpath(f\"build/runtime\")\n    os.makedirs(runtime_build_dir)\n    return compiler.binary(runtime_build_dir, libs, bin_opts)\n", "path": "python/tvm/micro/build.py"}], "after_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\n\"\"\"Defines top-level glue functions for building microTVM artifacts.\"\"\"\n\nimport copy\nimport logging\nimport os\nimport re\nfrom tvm.contrib import util\n\n\n_LOG = logging.getLogger(__name__)\n\n\nclass Workspace:\n    \"\"\"Defines helper functions for manipulating temporary compilation workspaces.\"\"\"\n\n    def __init__(self, root=None, debug=False):\n        if debug or root is not None:\n            with util.TempDirectory.set_keep_for_debug():\n                self.tempdir = util.tempdir(custom_path=root)\n                _LOG.info(\"Created debug mode workspace at: %s\", self.tempdir.temp_dir)\n        else:\n            self.tempdir = util.tempdir()\n\n    def relpath(self, path):\n        return self.tempdir.relpath(path)\n\n    def listdir(self):\n        return self.tempdir.listdir()\n\n    @property\n    def path(self):\n        return self.tempdir.temp_dir\n\n\n# Required C runtime libraries, in link order.\nCRT_RUNTIME_LIB_NAMES = [\"utvm_rpc_server\", \"utvm_rpc_common\", \"common\"]\n\n\nTVM_ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), \"..\", \"..\", \"..\"))\n\n\nCRT_ROOT_DIR = os.path.join(TVM_ROOT_DIR, \"src\", \"runtime\", \"crt\")\n\n\nRUNTIME_LIB_SRC_DIRS = [os.path.join(CRT_ROOT_DIR, n) for n in CRT_RUNTIME_LIB_NAMES] + [\n    os.path.join(TVM_ROOT_DIR, \"3rdparty/libcrc/src\")\n]\n\n\nRUNTIME_SRC_REGEX = re.compile(r\"^.*\\.cc?$\", re.IGNORECASE)\n\n\n_CRT_DEFAULT_OPTIONS = {\n    \"ccflags\": [\"-std=c++11\"],\n    \"ldflags\": [\"-std=gnu++14\"],\n    \"include_dirs\": [\n        f\"{TVM_ROOT_DIR}/include\",\n        f\"{TVM_ROOT_DIR}/3rdparty/dlpack/include\",\n        f\"{TVM_ROOT_DIR}/3rdparty/libcrc/include\",\n        f\"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include\",\n        f\"{CRT_ROOT_DIR}/include\",\n    ],\n    \"profile\": {\"common\": [\"-Wno-unused-variable\"]},\n}\n\n\ndef default_options(target_include_dir):\n    \"\"\"Return default opts passed to Compile commands.\"\"\"\n    bin_opts = copy.deepcopy(_CRT_DEFAULT_OPTIONS)\n    bin_opts[\"include_dirs\"].append(target_include_dir)\n    lib_opts = copy.deepcopy(bin_opts)\n    lib_opts[\"profile\"][\"common\"].append(\"-Werror\")\n    lib_opts[\"cflags\"] = [\"-Wno-error=incompatible-pointer-types\"]\n    return {\"bin_opts\": bin_opts, \"lib_opts\": lib_opts}\n\n\ndef build_static_runtime(workspace, compiler, module, lib_opts=None, bin_opts=None):\n    \"\"\"Build the on-device runtime, statically linking the given modules.\n\n    Parameters\n    ----------\n    compiler : tvm.micro.Compiler\n        Compiler instance used to build the runtime.\n\n    module : IRModule\n        Module to statically link.\n\n    lib_opts : dict\n        Extra kwargs passed to library(),\n\n    bin_opts : dict\n        Extra kwargs passed to binary(),\n\n    Returns\n    -------\n    MicroBinary :\n        The compiled runtime.\n    \"\"\"\n    lib_opts = _CRT_DEFAULT_OPTIONS if lib_opts is None else lib_opts\n    bin_opts = _CRT_DEFAULT_OPTIONS if bin_opts is None else bin_opts\n\n    mod_build_dir = workspace.relpath(os.path.join(\"build\", \"module\"))\n    os.makedirs(mod_build_dir)\n    mod_src_dir = workspace.relpath(os.path.join(\"src\", \"module\"))\n    os.makedirs(mod_src_dir)\n    mod_src_path = os.path.join(mod_src_dir, \"module.c\")\n    module.save(mod_src_path, \"cc\")\n\n    libs = []\n    for lib_src_dir in RUNTIME_LIB_SRC_DIRS:\n        lib_name = os.path.basename(lib_src_dir)\n        lib_build_dir = workspace.relpath(f\"build/{lib_name}\")\n        os.makedirs(lib_build_dir)\n\n        lib_srcs = []\n        for p in os.listdir(lib_src_dir):\n            if RUNTIME_SRC_REGEX.match(p):\n                lib_srcs.append(os.path.join(lib_src_dir, p))\n\n        libs.append(compiler.library(lib_build_dir, lib_srcs, lib_opts))\n\n    libs.append(compiler.library(mod_build_dir, [mod_src_path], lib_opts))\n\n    runtime_build_dir = workspace.relpath(f\"build/runtime\")\n    os.makedirs(runtime_build_dir)\n    return compiler.binary(runtime_build_dir, libs, bin_opts)\n", "path": "python/tvm/micro/build.py"}]}