Message ID | 20240807-macos-build-support-v1-4-4cd1ded85694@samsung.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Enable build system on macOS hosts | expand |
On Wed, Aug 07, 2024 at 01:09:18AM GMT, Daniel Gomez via B4 Relay wrote: >From: Daniel Gomez <da.gomez@samsung.com> > >Use getprogname() [1] instead of program_invocation_short_name() [2] >for macOS hosts. > >[1]: >https://www.gnu.org/software/gnulib/manual/html_node/ >program_005finvocation_005fshort_005fname.html > >[2]: >https://developer.apple.com/library/archive/documentation/System/ >Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html > >Fixes build error for macOS hosts: > >drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of >undeclared identifier 'program_invocation_short_name' 34 | >program_invocation_short_name); | ^ 1 error >generated. > >Signed-off-by: Daniel Gomez <da.gomez@samsung.com> >--- > drivers/gpu/drm/xe/xe_gen_wa_oob.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > >diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >index 904cf47925aa..079b8870c461 100644 >--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c >+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >@@ -9,6 +9,12 @@ > #include <stdbool.h> > #include <stdio.h> > #include <string.h> >+#define PROG_INV_NAME program_invocation_short_name >+ >+#ifdef __APPLE__ >+#include <stdlib.h> >+#define PROG_INV_NAME getprogname() >+#endif > > #define HEADER \ > "// SPDX-License-Identifier: MIT\n" \ >@@ -31,7 +37,7 @@ > static void print_usage(FILE *f) > { > fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n", >- program_invocation_short_name); >+ PROG_INV_NAME); instead of doing that, can we a) include stdlib.h unconditionally and b) add here a `static const char *program_invocation_short_name = getprogname()` so we don't need to change the common case and just handle the "build on macos" as a compat layer? Lucas De Marchi > } > > static void print_parse_error(const char *err_msg, const char *line, > >-- >Git-146) > >
On Tue, Aug 06, 2024 at 08:50:09PM GMT, Lucas De Marchi wrote: > On Wed, Aug 07, 2024 at 01:09:18AM GMT, Daniel Gomez via B4 Relay wrote: > > From: Daniel Gomez <da.gomez@samsung.com> > > > > Use getprogname() [1] instead of program_invocation_short_name() [2] > > for macOS hosts. > > > > [1]: > > https://www.gnu.org/software/gnulib/manual/html_node/ > > program_005finvocation_005fshort_005fname.html > > > > [2]: > > https://developer.apple.com/library/archive/documentation/System/ > > Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html > > > > Fixes build error for macOS hosts: > > > > drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of > > undeclared identifier 'program_invocation_short_name' 34 | > > program_invocation_short_name); | ^ 1 error > > generated. > > > > Signed-off-by: Daniel Gomez <da.gomez@samsung.com> > > --- > > drivers/gpu/drm/xe/xe_gen_wa_oob.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c > > index 904cf47925aa..079b8870c461 100644 > > --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c > > +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c > > @@ -9,6 +9,12 @@ > > #include <stdbool.h> > > #include <stdio.h> > > #include <string.h> > > +#define PROG_INV_NAME program_invocation_short_name > > + > > +#ifdef __APPLE__ > > +#include <stdlib.h> > > +#define PROG_INV_NAME getprogname() > > +#endif > > > > #define HEADER \ > > "// SPDX-License-Identifier: MIT\n" \ > > @@ -31,7 +37,7 @@ > > static void print_usage(FILE *f) > > { > > fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n", > > - program_invocation_short_name); > > + PROG_INV_NAME); > > instead of doing that, can we a) include stdlib.h unconditionally and b) > add here a > `static const char *program_invocation_short_name = getprogname()` so we > don't need to change the common case and just handle the "build on > macos" as a compat layer? Does this align with your suggestion (v1 diff)? Note that static cannot be use here. diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c index 079b8870c461..b3add20ccb01 100644 --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c @@ -9,12 +9,7 @@ #include <stdbool.h> #include <stdio.h> #include <string.h> -#define PROG_INV_NAME program_invocation_short_name - -#ifdef __APPLE__ #include <stdlib.h> -#define PROG_INV_NAME getprogname() -#endif #define HEADER \ "// SPDX-License-Identifier: MIT\n" \ @@ -36,8 +31,11 @@ static void print_usage(FILE *f) { +#ifdef __APPLE__ + const char *program_invocation_short_name = getprogname(); +#endif fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n", - PROG_INV_NAME); + program_invocation_short_name); } static void print_parse_error(const char *err_msg, const char *line, > > Lucas De Marchi > > > } > > > > static void print_parse_error(const char *err_msg, const char *line, > > > > -- > > Git-146) > > > >
On Wed, Aug 07, 2024 at 08:13:51AM GMT, Daniel Gomez wrote: >On Tue, Aug 06, 2024 at 08:50:09PM GMT, Lucas De Marchi wrote: >> On Wed, Aug 07, 2024 at 01:09:18AM GMT, Daniel Gomez via B4 Relay wrote: >> > From: Daniel Gomez <da.gomez@samsung.com> >> > >> > Use getprogname() [1] instead of program_invocation_short_name() [2] >> > for macOS hosts. >> > >> > [1]: >> > https://www.gnu.org/software/gnulib/manual/html_node/ >> > program_005finvocation_005fshort_005fname.html >> > >> > [2]: >> > https://developer.apple.com/library/archive/documentation/System/ >> > Conceptual/ManPages_iPhoneOS/man3/getprogname.3.html >> > >> > Fixes build error for macOS hosts: >> > >> > drivers/gpu/drm/xe/xe_gen_wa_oob.c:34:3: error: use of >> > undeclared identifier 'program_invocation_short_name' 34 | >> > program_invocation_short_name); | ^ 1 error >> > generated. >> > >> > Signed-off-by: Daniel Gomez <da.gomez@samsung.com> >> > --- >> > drivers/gpu/drm/xe/xe_gen_wa_oob.c | 8 +++++++- >> > 1 file changed, 7 insertions(+), 1 deletion(-) >> > >> > diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >> > index 904cf47925aa..079b8870c461 100644 >> > --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c >> > +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >> > @@ -9,6 +9,12 @@ >> > #include <stdbool.h> >> > #include <stdio.h> >> > #include <string.h> >> > +#define PROG_INV_NAME program_invocation_short_name >> > + >> > +#ifdef __APPLE__ >> > +#include <stdlib.h> >> > +#define PROG_INV_NAME getprogname() >> > +#endif >> > >> > #define HEADER \ >> > "// SPDX-License-Identifier: MIT\n" \ >> > @@ -31,7 +37,7 @@ >> > static void print_usage(FILE *f) >> > { >> > fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n", >> > - program_invocation_short_name); >> > + PROG_INV_NAME); >> >> instead of doing that, can we a) include stdlib.h unconditionally and b) >> add here a >> `static const char *program_invocation_short_name = getprogname()` so we >> don't need to change the common case and just handle the "build on >> macos" as a compat layer? > >Does this align with your suggestion (v1 diff)? yes, just a nit that in xe we keep the includes sorted alphabetically, so the stdlib.h include should move up one line. Other than that, // Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> ... assuming the rest of the series and idea about building the kernel on macOS is not pushed back. Lucas De Marchi > >Note that static cannot be use here. > >diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >index 079b8870c461..b3add20ccb01 100644 >--- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c >+++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c >@@ -9,12 +9,7 @@ > #include <stdbool.h> > #include <stdio.h> > #include <string.h> >-#define PROG_INV_NAME program_invocation_short_name >- >-#ifdef __APPLE__ > #include <stdlib.h> >-#define PROG_INV_NAME getprogname() >-#endif > > #define HEADER \ > "// SPDX-License-Identifier: MIT\n" \ >@@ -36,8 +31,11 @@ > > static void print_usage(FILE *f) > { >+#ifdef __APPLE__ >+ const char *program_invocation_short_name = getprogname(); >+#endif > fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n", >- PROG_INV_NAME); >+ program_invocation_short_name); > } > > static void print_parse_error(const char *err_msg, const char *line, > >> >> Lucas De Marchi >> >> > } >> > >> > static void print_parse_error(const char *err_msg, const char *line, >> > >> > -- >> > Git-146) >> > >> >
diff --git a/drivers/gpu/drm/xe/xe_gen_wa_oob.c b/drivers/gpu/drm/xe/xe_gen_wa_oob.c index 904cf47925aa..079b8870c461 100644 --- a/drivers/gpu/drm/xe/xe_gen_wa_oob.c +++ b/drivers/gpu/drm/xe/xe_gen_wa_oob.c @@ -9,6 +9,12 @@ #include <stdbool.h> #include <stdio.h> #include <string.h> +#define PROG_INV_NAME program_invocation_short_name + +#ifdef __APPLE__ +#include <stdlib.h> +#define PROG_INV_NAME getprogname() +#endif #define HEADER \ "// SPDX-License-Identifier: MIT\n" \ @@ -31,7 +37,7 @@ static void print_usage(FILE *f) { fprintf(f, "usage: %s <input-rule-file> <generated-c-source-file> <generated-c-header-file>\n", - program_invocation_short_name); + PROG_INV_NAME); } static void print_parse_error(const char *err_msg, const char *line,