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

"' @bmk"-pragma ignored in application main source file #123

Open
GWRon opened this issue Jul 1, 2023 · 2 comments
Open

"' @bmk"-pragma ignored in application main source file #123

GWRon opened this issue Jul 1, 2023 · 2 comments

Comments

@GWRon
Copy link
Contributor

GWRon commented Jul 1, 2023

SuperStrict

' @bmk echo *** Building my cool app ***
' @bmk addccopt -DSPECIAL_OPTION
print "hello"

Compiling this code leads to about the following (added some "prints:

Building untitled1
Loading /BlitzMaxNG/bin/custom.bmk
TBMKGlobals.AddOption: variable=ld_opts key=static-stdc value=-static-libstdc++
MakeApp() called
->   globals.Get(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 
->   source.cc_opts = 
....
TModOpt.addOption: qval=Authors: Mark Sibly, Simon Armstrong
....
TModOpt.addOption: qval=CC_OPTS: -DGC_THREADS -D_REENTRANT -DPARALLEL_MARK -DATOMIC_UNCOLLECTABLE -DLARGE_CONFIG -DUSE_MMAP -DUSE_MUNMAP -DMUNMAP_THRESHOLD=3

[ 23%] Processing:untitled1.bmx
*** Building my cool app ***
arg1: -DSPECIAL_OPTION
TBMKGlobals.AddOption: variable=cc_opts key=-DSPECIAL_OPTION value=
/BlitzMaxNG/bin/bcc  -g x64 -v -h -s -w -t gui -p linux -o ...
...
[ 85%] Compiling:untitled1.bmx.gui.debug.linux.x64.c
gcc -I/BlitzMaxNG/mod -I/BlitzMaxNG/mod/brl.mod/blitz.mod ...
[100%] Linking:untitled1.debug
g++ -m64 -no-pie -fpie -pthread -o /BlitzMaxNG/tmp/untitled1.debug ...
Executing:untitled1.debug

this looks like the cc_opt of the main file is not used for compiling the mainfile.

@GWRon
Copy link
Contributor Author

GWRon commented Jul 1, 2023

I appended some further debug prints:
changes the output of:

	Method DoBuild(makelib:Int, app_build:Int = False)
...
					Select m.stage
...
						Case STAGE_OBJECT
...
							If processor.BCCVersion() <> "BlitzMax" Then
...
									print "m.cc_opts = " + m.cc_opts
									print "  cc_opts = " + cc_opts
									print "  processor.Option(cc_opts) = " + processor.Option("cc_opts", "")
									print "  globals.Option(cc_opts) = " + globals.Get("cc_opts")

Changing the line from
' @bmk addccopt -DSPECIAL_OPTION to
' @bmk addccopt mykey -DSPECIAL_OPTION

leads to "-DSPECIAL_OPTION" being listed for the "globals" (but not in "[m.]cc_opts")

old:

[ 85%] Compiling:untitled1.bmx.gui.debug.linux.x64.c
m.cc_opts = 
  cc_opts = 
  processor.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3
  globals.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 

new:

[ 85%] Compiling:untitled1.bmx.gui.debug.linux.x64.c
m.cc_opts = 
  cc_opts = 
  processor.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION 
  globals.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION 

@GWRon
Copy link
Contributor Author

GWRon commented Jul 1, 2023

Placing a "pre.bmk" next to my untitled1.bmx (aka unsaved file in maxide):

addccopt mykey -DSPECIAL_OPTION23

results in

Building untitled1
Loading /BlitzMaxNG/bin/custom.bmk
TBMKGlobals.AddOption: variable=ld_opts key=static-stdc value=-static-libstdc++
Loading /BlitzMaxNG/tmp/pre.bmk
arg1: mykey
TBMKGlobals.AddOption: variable=cc_opts key=mykey value=-DSPECIAL_OPTION23
globals.Get(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION23 
processor.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION23 
source.cc_opts = 

[ 85%] Compiling:untitled1.bmx.gui.debug.linux.x64.c
m.cc_opts = 
  cc_opts = 
  processor.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION23  
  globals.Option(cc_opts) =  -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION23  
gcc -IBlitzMaxNG/mod 
	-IBlitzMaxNG/mod/brl.mod/blitz.mod 
	-IBlitzMaxNG/mod/brl.mod/appstub.mod 
	...
	-w -DBMX_NG -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -DSPECIAL_OPTION23
	-g -o BlitzMaxNG/tmp/.bmx/untitled1.bmx.gui.debug.linux.x64.o BlitzMaxNG/tmp/.bmx/untitled1.bmx.gui.debug.linux.x64.c


Executing:untitled1.debug
/BlitzMaxNG/tmp/untitled1.debug
hello

Process complete

So this step works (but also requires a "key"). The "key" information is missing in the docs:
https://blitzmax.org/docs/en/language/pre_post_compilation_scripts/

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