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

Missing equivalent to -M flags like for gcc/clang/swift #1926

Open
KaruroChori opened this issue Feb 3, 2025 · 0 comments
Open

Missing equivalent to -M flags like for gcc/clang/swift #1926

KaruroChori opened this issue Feb 3, 2025 · 0 comments

Comments

@KaruroChori
Copy link

KaruroChori commented Feb 3, 2025

This requires #1925 to be handled first.

Many downstream build systems, like ninja/samurai expects the compiler to be able to generate a dependency map for each file.
Its conventional format is as in a makefile entry in the form targets: prerequisites.

For reference, flags -Mx discussed in https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

For example, a basic C hello world example like

#include <stdio.h>
int main() {
  printf("hello world");
  return 0;
}

gcc test.c -M would result in the following map:

test.o: test.c /usr/include/stdc-predef.h /usr/include/stdio.h \
 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
 /usr/include/features.h /usr/include/features-time64.h \
 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
 /usr/include/x86_64-linux-gnu/bits/timesize.h \
 /usr/include/x86_64-linux-gnu/sys/cdefs.h \
 /usr/include/x86_64-linux-gnu/bits/long-double.h \
 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
 /usr/local/gcc-14.2.0/lib/gcc/x86_64-linux-gnu/14.2.0/include/stddef.h \
 /usr/local/gcc-14.2.0/lib/gcc/x86_64-linux-gnu/14.2.0/include/stdarg.h \
 /usr/include/x86_64-linux-gnu/bits/types.h \
 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
 /usr/include/x86_64-linux-gnu/bits/time64.h \
 /usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
 /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
 /usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
 /usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h \
 /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
 /usr/include/x86_64-linux-gnu/bits/floatn.h \
 /usr/include/x86_64-linux-gnu/bits/floatn-common.h

Not each of those flags needs implementation, and most are very similar, just combinatorial variants.
Like, if system headers are to be listed or not.

@KaruroChori KaruroChori changed the title Missing equivalent to -M flags in gcc/clang/swift Missing equivalent to -M flags like for gcc/clang/swift Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant