diff --git a/BUILD.gn b/BUILD.gn index 4ba2c2ff65ce0a2a5b258b97952027a0478bad5b..045d69ee82753b8922f8589cac761c3e2cef4f72 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -307,6 +307,24 @@ config("public") { } } +sysroot_path = rebase_path(ohos_current_sysroot) +config("sysroot_flags") { + if (ohos_build_compiler == "clang") { + cflags = [ + "--target=$target_triple", + "--sysroot=$sysroot_path", + ] + } else { + cflags = [ + "--sysroot=$sysroot_path", + "-specs=musl-gcc.specs", + ] + } + cflags_cc = cflags + ldflags = cflags + asmflags = cflags +} + group("modules") { deps = [ "arch", @@ -363,7 +381,10 @@ executable("liteos") { configs = [] # clear default configs configs += [ ":arch_config" ] configs += [ ":public" ] - + if (is_lite_system && current_os == "ohos" && !is_mini_system && + !ohos_kernel_is_prebuilt) { + configs += [ ":sysroot_flags" ] + } ldflags = [ "-static", "-nostdlib", diff --git a/liteos.gni b/liteos.gni index 6deef9944b254ecba4435868f7bd526a61bad1cd..f5142627615462bc518f6fa0c3154540c8f9246b 100644 --- a/liteos.gni +++ b/liteos.gni @@ -90,6 +90,7 @@ template("kernel_module") { } else { source_set(target_name) { public_configs = [] + configs = [] forward_variables_from(invoker, "*") if (has_public_config) { included_public_config = false @@ -103,6 +104,10 @@ template("kernel_module") { public_configs += [ ":public" ] } } + if (is_lite_system && current_os == "ohos" && !is_mini_system && + !ohos_kernel_is_prebuilt) { + configs += [ "$LITEOSTOPDIR:sysroot_flags" ] + } } } not_needed([ "auto_config" ])