Frogging-Family / mesa-git

Other
46 stars 22 forks source link

Cflags get applied twice #3

Closed random2324 closed 3 years ago

random2324 commented 4 years ago

I actually dont know it this is an error on my side. But it seems that the PKGBUILD apply the cflags twice. One from the system and another one from the config file.

      export CFLAGS="${CFLAGS} ${_custom_opt_flags}"
      export CPPFLAGS="${CPPFLAGS} ${_custom_opt_flags}"
      export CXXFLAGS="${CXXFLAGS} ${_custom_opt_flags}"

Anyway, this is how it looks on my end:

Using 'CC' from environment with value: 'gcc -m32'
Using 'CFLAGS' from environment with value: '-O2 -pipe -march=native -fstack-protector-strong -fno-plt -march=native -fno-tree-vectorize -O3'
Using 'LDFLAGS' from environment with value: '-Wl,-O2,--sort-common,--as-needed,-z,relro'
Using 'CPPFLAGS' from environment with value: '-D_FORTIFY_SOURCE=2 -march=native -fno-tree-vectorize -O3'
Using 'CXX' from environment with value: 'g++ -m32'
Using 'CXXFLAGS' from environment with value: '-O2 -pipe -march=native -fstack-protector-strong -fno-plt -march=native -fno-tree-vectorize -O3'
Using 'LDFLAGS' from environment with value: '-Wl,-O2,--sort-common,--as-needed,-z,relro'
Using 'CPPFLAGS' from environment with value: '-D_FORTIFY_SOURCE=2 -march=native -fno-tree-vectorize -O3'
Using 'CC' from environment with value: 'gcc -m32'
Using 'CFLAGS' from environment with value: '-O2 -pipe -march=native -fstack-protector-strong -fno-plt -march=native -fno-tree-vectorize -O3'
Using 'LDFLAGS' from environment with value: '-Wl,-O2,--sort-common,--as-needed,-z,relro'
Using 'CPPFLAGS' from environment with value: '-D_FORTIFY_SOURCE=2 -march=native -fno-tree-vectorize -O3'

I turned this now into:

      export CFLAGS=" ${_custom_opt_flags}"
      export CPPFLAGS=" ${_custom_opt_flags}"
      export CXXFLAGS=" ${_custom_opt_flags}"

And received:

Using 'CC' from environment with value: 'gcc -m32'
Using 'CFLAGS' from environment with value: '-march=native -fno-tree-vectorize -O3'
Using 'LDFLAGS' from environment with value: '-Wl,-O2,--sort-common,--as-needed,-z,relro'
Using 'CPPFLAGS' from environment with value: '-march=native -fno-tree-vectorize -O3'
Using 'CXX' from environment with value: 'g++ -m32'
Using 'CXXFLAGS' from environment with value: '-march=native -fno-tree-vectorize -O3'
Using 'LDFLAGS' from environment with value: '-Wl,-O2,--sort-common,--as-needed,-z,relro'
Using 'CPPFLAGS' from environment with value: '-march=native -fno-tree-vectorize -O3'
Using 'CC' from environment with value: 'gcc -m32'
Using 'CFLAGS' from environment with value: '-march=native -fno-tree-vectorize -O3'
Using 'LDFLAGS' from environment with value: '-Wl,-O2,--sort-common,--as-needed,-z,relro'
Using 'CPPFLAGS' from environment with value: '-march=native -fno-tree-vectorize -O3'

Even though ninja summary still looking wrong:

 Compiler options           Current Value                                                                         Possible Values                                               Description
  ----------------           -------------                                                                         ---------------                                               -----------
  c_args                     [-march=native, -fno-tree-vectorize, -O3, -march=native, -fno-tree-vectorize, -O3]                                                                  Extra arguments passed to the c compiler
  c_link_args                [-march=native, -fno-tree-vectorize, -O3, -Wl,-O2,--sort-common,--as-needed,-z,relro]                                                               Extra arguments passed to the c linker
  c_std                      c99                                                                                   [none, c89, c99, c11, c17, c18, gnu89, gnu99, gnu11, gnu17,   C language standard to use
                                                                                                                    gnu18]                                                       
  cpp_args                   [-march=native, -fno-tree-vectorize, -O3, -march=native, -fno-tree-vectorize, -O3]                                                                  Extra arguments passed to the cpp compiler
  cpp_debugstl               false                                                                                 [true, false]                                                 STL debug mode
  cpp_eh                     default                                                                               [none, default, a, s, sc]                                     C++ exception handling type.
  cpp_link_args              [-march=native, -fno-tree-vectorize, -O3, -Wl,-O2,--sort-common,--as-needed,-z,relro]        

So I dont know if thats intended. Maybe its also a bad idea to make -march=native the default system wide. On the other hand shouldnt be the intention of the config file to override my cflags?

sudoBash418 commented 4 years ago

On the other hand shouldnt be the intention of the config file to override my cflags?

If my understanding is correct, that's exactly what you're doing: flags that come later override the previous ones (for instance, if you have -O3, the compiler will just ignore the system-wide default of -O2), so having "flags applied twice" doesn't really affect anything.

Tk-Glitch commented 3 years ago

sudoBash418 explained it all :+1: Closing.