AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Someone explain to me why this happening? (https://forums.alliedmods.net/showthread.php?t=285672)

WildCard65 07-27-2016 20:08

Someone explain to me why this happening?
 
Ok so I'm working on an SM Ext/AMXX Module (code compiles fine on both SM API and AMXX api in current stage) but I noticed something wierd.

As I already know, SM and AMXX (Not 100% sure if true for AMXX) are compiled with clang,
my project is setup to work on clang-3.8 and gcc(g++)-4.8
Wierd part: Binary size of binary compiled with clang is roughly 2x bigger then version under gcc/g++
PHP Code:

Sizes:
  
AMXX API:
    
clang520KB
    gcc
223KB
  SM API
:
    
clang478KB
    gcc
217KB 

The project statically compiles and links latest source of libbz2 and zlib (at time of thread post) during AMBuild process. Compile flags is as minimal warning disabling as possible (CXX projects get the exception mismatch warning disabled due to SM/AMXX api requiring it), 2 other flags are added onto building 3rd party project code(1 per 3rd party build, other doesn't get it)
Builds were set for optimization (-O3)

Anyone explain to me why clang is producing 2x bigger binary when code variance is practically none existent (except between which API being built against)?

Edit: Digging around compiled files for the project yielded the heavy file size hitters for building with clang being the third party code(zlib, bzip2), zlib ranking highest for most file size.

Powerlord 07-28-2016 03:38

Re: Someone explain to me why this happening?
 
It would help if we knew which compile flags and/or methods you were using.

Edit: There's likely a reason that the SM AMBuildScript adds in compiler-specific flags for GCC and Clang, sometimes even for specific versions of these compilers.

WildCard65 07-28-2016 06:58

Re: Someone explain to me why this happening?
 
Flags for all 3 projects:
PHP Code:

cxx.cflags += ( '-pipe''-Wall''-Werror''-msse''-m32''-fvisibility=hidden' )
cxx.cxxflags += ( '-std=c++11''-fno-exceptions''-fvisibility-inlines-hidden' )
cxx.linkflags.append('-m32')

if 
cxx.family == 'gcc':
  
cxx.cflags.append('-mfpmath=sse')

if 
builder.options.build_type == 'optimize':
  
cxx.cflags.append('-O3')

cxx.cflags.append('-fno-omit-frame-pointer'

BZip2 extra flag:
PHP Code:

if bz2_builder.compiler.family == 'gcc':
  
bz2_builder.compiler.cflags.append('-Wno-maybe-uninitialized'

Zlib extra flag:
PHP Code:

if z_builder.compiler.family == 'clang':
  
z_builder.compiler.cflags.append('-Wno-shift-negative-value'

AMXX/SM specific flag:
PHP Code:

if binary_builder.compiler.family == 'clang':
  
binary_builder.compiler.cflags.append('-Wno-implicit-exception-spec-mismatch'

SM specific flag:
PHP Code:

if binary_builder.compiler.like('gcc'):
  
binary_builder.compiler.cflags.append('-Wno-strict-aliasing'



All times are GMT -4. The time now is 05:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.