Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-scan-deps commandline misses target flags on command line #6028

Open
redstar opened this issue Dec 31, 2024 · 1 comment
Open

clang-scan-deps commandline misses target flags on command line #6028

redstar opened this issue Dec 31, 2024 · 1 comment
Labels

Comments

@redstar
Copy link

redstar commented Dec 31, 2024

Xmake Version

v2.9.7+dev.b029e65ed

Operating System Version and Architecture

Ubuntu 24.10 x86_64

Describe Bug

The Include directories added to the target inside a rule are not added to the flags of clang-scan-deps, resulting in a compile error.

It seems that the added options depend on the first file/target scanned. If target src2 is removed from xmake.lua then the option is added as expected, and the source compiles fine.

Expected Behavior

Running xmake config --toolchain=clang -v, the include directory added in the rule should be added to the command line of clang-scan-deps, too. It works this way for normal C++ compilation units, but not for C++20 modules. The idea here is to have a private include file only used in the module body (e.g. a database file / generated code).

Project Configuration

set_languages("c++20")

add_rules("mode.debug", "mode.release")

rule("include")
    before_config(function (target)
        print("include.before_config")
        target:add("includedirs", "$(projectdir)/src1/include")
    end)

target("src1")
    set_kind("static")
    add_rules("include")
    add_files("src1/*.cppm", {public = true})

target("src2")
    set_kind("binary")
    add_deps("src1")
    add_files("src2/*.cpp")

Additional Information and Error Logs

// src1/bar.cppm
module;

export module bar;

#include "foo.h"

export int bar() {
  return foo();
}
// src1/include/foo.h
int foo(); 
// src2/main.cpp
import bar;

int main() {
  return foo();
}

Configuration output:

xmake config --toolchain=clang -v
include.before_config
configure
{
    buildir = build
    ccache = true
    ndk_stdcxx = true
    host = linux
    arch = x86_64
    kind = static
    plat = linux
    toolchain = clang
    mode = release
}
xmake build -v
include.before_config
[  0%]: <src2> generating.module.deps src1/bar.cppm
/usr/bin/clang-scan-deps --format=p1689 -- /usr/bin/clang -x c++ -c src1/bar.cppm -o build/.objs/src2/linux/x86_64/release/src1/bar.cppm.o -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -DNDEBUG
error: Error while scanning dependencies for src1/bar.cppm:
src1/bar.cppm:5:10: fatal error: 'foo.h' file not found

warning: std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++
@redstar redstar added the bug label Dec 31, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: clang-scan-deps commandline misses target flags on command line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants