SConscript
1 # 2 # Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved. 3 # 4 # Redistribution and use in source and binary forms, with or without modification, 5 # are permitted provided that the following conditions are met: 6 # 1. Redistributions of source code must retain the above copyright notice, 7 # this list of conditions and the following disclaimer. 8 # 2. Redistributions in binary form must reproduce the above copyright notice, 9 # this list of conditions and the following disclaimer in the documentation 10 # and/or other materials provided with the distribution. 11 # 3. Neither the name of the copyright holder nor the names of its contributors 12 # may be used to endorse or promote products derived from this software without 13 # specific prior written permission. 14 # 15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 21 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 # POSSIBILITY OF SUCH DAMAGE. 25 26 # Inherit global environment 27 Import('env') 28 from os.path import join as joinpath 29 30 e = env.Clone() 31 32 # These rearrangements are not value-safe: 33 # (a ⊕ b) ⊕ c ⇒ a ⊕ (b ⊕ c) 34 # a ⊗ (b ⊕ c) ⇒ (a ⊗ b) ⊕ (a ⊕ c) 35 # 36 # To Disallow these changes in gcc remove -ffast-math 37 if '-ffast-math' in e['CFLAGS']: 38 e['CFLAGS'].remove('-ffast-math') 39 40 e.Append( 41 CFLAGS = ['-fPIC'] 42 ) 43 44 try: 45 dbg_mode=env['debug_mode'] 46 except KeyError as err: 47 print("Keyerror, debug_mode not found, setting to none", err) 48 dbg_mode='none' 49 50 if dbg_mode == 'libs' or dbg_mode == 'all': 51 e.Append( 52 CCFLAGS = ['-g'] 53 ) 54 # remove all optimizations on command line 55 opt_list=["-O%s"%x for x in range(1, 10)] 56 opt_list.append('-Os') 57 for opt in opt_list: 58 try: 59 e['CFLAGS'].remove(opt) 60 except ValueError as err: 61 pass 62 else: 63 e.Append( 64 CCFLAGS = ['-O3'], 65 ) 66 67 experiment_src=[ 68 ] 69 70 source = Glob('*.c', exclude=experiment_src) 71 #source = Glob('*.c') 72 73 objs = e.StaticObject(source) 74 75 Return('objs')