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

Add flags for specific compilers and linkers #3022

Closed
waruqi opened this issue Nov 4, 2022 · 5 comments
Closed

Add flags for specific compilers and linkers #3022

waruqi opened this issue Nov 4, 2022 · 5 comments

Comments

@waruqi
Copy link
Member

waruqi commented Nov 4, 2022

Is your feature request related to a problem? Please describe.

Usually, we need to add specific flags in the script scope in order to determine the compiler name.

target("test")
    on_config(function (target)
         if target:has_tool("cxx", "clang") then
             target:add("cxxflags", "-stdlib=libc++")
         end
    end)

Describe the solution you'd like

Better solution1

For the same flags, we can also easily append them to different.

However, it can only be used for compilation tools and cannot be extended to other types.

add_cxxflags("clang::-stdlib=libc++")
add_cxxflags("gcc::-stdlib=libc++")

and if there are a lot of flags, it will be add_cxxflags("clang::-stdlib=libc++", "clang::xxx", "clang::yyy", "clang::zz")

Better solution2

add_cxxflags("-stdlib=libc++", {tools = "clang"})
add_cxxflags("-stdlib=libc++", {tools = "gcc"})

it will override tools, always is gcc

Other solutions

...

It will override tools, it always is gcc.

Describe alternatives you've considered

No response

Additional context

No response

@waruqi waruqi added this to the v2.7.3 milestone Nov 4, 2022
@waruqi
Copy link
Member Author

waruqi commented Nov 4, 2022

I have supported both solutions.

@Jeangowhy
Copy link

it doesn't work in Windows 10 MinGW GCC. Much more, flags can't cover the default value:

    add_cxxflags("-fmodules-ts", { tools = "gcc" })
    add_cxxflags("-o module-ixx", { tools = "gcc" })

C:\mingw-w64\x86_64-12.2.0-release-win32-seh-ucrt-rt_v10-rev2\bin\x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++20 module-ixx/hello.ixx module-ixx/world.ixx -o build\.objs\module-ixx\mingw\x86_64\debug\modules_ixx\app.cpp.obj modules_ixx\app.cpp

@adamdusty
Copy link

it doesn't work in Windows 10 MinGW GCC. Much more, flags can't cover the default value:

    add_cxxflags("-fmodules-ts", { tools = "gcc" })
    add_cxxflags("-o module-ixx", { tools = "gcc" })

C:\mingw-w64\x86_64-12.2.0-release-win32-seh-ucrt-rt_v10-rev2\bin\x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++20 module-ixx/hello.ixx module-ixx/world.ixx -o build\.objs\module-ixx\mingw\x86_64\debug\modules_ixx\app.cpp.obj modules_ixx\app.cpp

I'm having the same issue, and haven't found a resolution. I'm curious if it has anything to do with mingw being treated as cross compilation.

@waruqi
Copy link
Member Author

waruqi commented Sep 1, 2023

tools = "gxx"

@Issues-translate-bot
Copy link

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


tools = "gxx"

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

No branches or pull requests

4 participants