diff --git a/recipes-openharmony/prebuilts/oniro-openharmony-toolchain-integration-3.1.inc b/recipes-openharmony/prebuilts/oniro-openharmony-toolchain-integration-3.1.inc
index e9883c246f8902395d031fdbb7b7fd18bf90af17..de5b33a122d64abb3549d7f3a9569c99872f7d9a 100644
--- a/recipes-openharmony/prebuilts/oniro-openharmony-toolchain-integration-3.1.inc
+++ b/recipes-openharmony/prebuilts/oniro-openharmony-toolchain-integration-3.1.inc
@@ -16,3 +16,4 @@ SRC_URI += "file://patches/productdefine_common.patch;apply=no;subdir=src"
 SRC_URI += "file://patches/third_party_libevdev.patch;apply=no;subdir=src"
 SRC_URI += "file://patches/third_party_libusb.patch;apply=no;subdir=src"
 SRC_URI += "file://patches/third_party_e2fsprogs-backports-to-3.1.patch;apply=no;subdir=src"
+SRC_URI += "file://patches/third_party_selinux.patch;apply=no;subdir=src"
diff --git a/recipes-openharmony/prebuilts/openharmony-3.1/patches/third_party_selinux.patch b/recipes-openharmony/prebuilts/openharmony-3.1/patches/third_party_selinux.patch
new file mode 100644
index 0000000000000000000000000000000000000000..73085d39bdf610f763fe2fe44db01daffd76031f
--- /dev/null
+++ b/recipes-openharmony/prebuilts/openharmony-3.1/patches/third_party_selinux.patch
@@ -0,0 +1,29 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+Patch for //third_party/selinux git repository of OpenHarmony 3.1 codebase.
+
+This disables the _FORTIFY_SOURCE macro for native build with gcc.
+This fixes the following compiler error for libselinux:
+ "error: inlining failed in call to always_inline ‘syslog’: function body can be overwritten at link time"
+
+Signed-off-by: Thierry Escande <thierry.escande@huawei.com>
+Upstream-Status: Inappropriate
+
+diff --git a/third_party/selinux/BUILD.gn b/third_party/selinux/BUILD.gn
+index 34616600..a9ca7cf5 100644
+--- a/third_party/selinux/BUILD.gn
++++ b/third_party/selinux/BUILD.gn
+@@ -199,6 +199,11 @@ ohos_shared_library("libselinux") {
+     "-DAUDITD_LOG_TAG=1003",
+     "-DPCRE2_CODE_UNIT_WIDTH=8",
+   ]
++
++  if (!is_clang) {
++    cflags += [ "-U_FORTIFY_SOURCE" ]
++  }
++
+   deps = [
+     ":libsepol",
+     "$LIBPCRE2_ROOT_DIR:libpcre2",