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

Fix build on FIPS-enabled systems #13

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build
demos/*/build*
playground/*/build*
.waf-*
.waf3-*
*.log
.DS_Store
.AppleDouble
Expand Down
16 changes: 8 additions & 8 deletions playground/compress/optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ def compare(a, b):
LEN = len(lst)

POP = 3*LEN + 1
popul = [range(LEN) for x in xrange(POP)]
fitn = [0 for x in xrange(POP)]
popul = [range(LEN) for x in range(POP)]
fitn = [0 for x in range(POP)]

def rnd():
return random.randint(0, LEN -1)

def mutate():
for x in xrange(LEN):
for x in range(LEN):
# rotate the previous element by one
v = popul[x+LEN] = popul[x+LEN - 1]
a = v.pop(0)
v.append(a)

for x in xrange(LEN):
for x in range(LEN):
# swap elements
a = rnd()
b = rnd()
Expand All @@ -66,7 +66,7 @@ def mutate():
v[a] = v[b]
v[b] = c

for x in xrange(LEN):
for x in range(LEN):
# get one element out, add at the end
v = popul[x+2*LEN]

Expand All @@ -79,7 +79,7 @@ def evil():

best = opti_ref
pos = -1
for x in xrange(len(popul)):
for x in range(len(popul)):
v = popul[x]
arr = [lst[a] for a in v]
tmp = '%s %s' % (cmd, ' '.join(arr))
Expand All @@ -99,14 +99,14 @@ def evil():
assert (sum(popul[x]) == sum(range(LEN)))

#print pos
for x in xrange(len(popul)):
for x in range(len(popul)):
if x == pos:
continue
popul[x] = popul[pos][:]
assert(len(popul[x]) == LEN)
return best

for i in xrange(10000):
for i in range(10000):
mutate()
print(evil())

Expand Down
2 changes: 1 addition & 1 deletion waf-light
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.

import os, sys, inspect

VERSION="2.0.8"
VERSION="2.0.9"
REVISION="x"
GIT="x"
INSTALL="x"
Expand Down
2 changes: 1 addition & 1 deletion waflib/Build.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def add_group(self, name=None, move=True):
:raises: :py:class:`waflib.Errors.WafError` if a group by the name given already exists
"""
if name and name in self.group_names:
raise Errors.WafError('add_group: name %s already present', name)
raise Errors.WafError('add_group: name %s already present' % name)
g = []
self.group_names[name] = g
self.groups.append(g)
Expand Down
2 changes: 1 addition & 1 deletion waflib/ConfigSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def load(self, filename):
:type filename: string
"""
tbl = self.table
code = Utils.readf(filename, m='rU')
code = Utils.readf(filename, m='r')
for m in re_imp.finditer(code):
g = m.group
tbl[g(2)] = eval(g(3))
Expand Down
8 changes: 4 additions & 4 deletions waflib/Context.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import waflib.Node

# the following 3 constants are updated on each new release (do not touch)
HEXVERSION=0x2000800
HEXVERSION=0x2000900
"""Constant updated on new releases"""

WAFVERSION="2.0.8"
WAFVERSION="2.0.9"
"""Constant updated on new releases"""

WAFREVISION="f78fbc32bb355a3291c9b5f79bbe0c8dfe81282a"
WAFREVISION="8a950e7bca9a3a9b1ae62aae039ef76e2adc4177"
"""Git revision when the waf version is updated"""

ABI = 20
Expand Down Expand Up @@ -662,7 +662,7 @@ def load_module(path, encoding=None):

module = imp.new_module(WSCRIPT_FILE)
try:
code = Utils.readf(path, m='rU', encoding=encoding)
code = Utils.readf(path, m='r', encoding=encoding)
except EnvironmentError:
raise Errors.WafError('Could not read the file %r' % path)

Expand Down
11 changes: 11 additions & 0 deletions waflib/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,17 @@ def abspath(self):
self.cache_abspath = val
return val

def relpath(self):
"""
Returns the relative path. This is used in place of abspath() to keep paths short
for environments like cygwin where path lengths to file operations are severely limited
(for example, when cross-compiling for arm-none-eabi on cygwin)

:rtype: string
"""
return os.path.relpath(self.abspath())


def is_child_of(self, node):
"""
Returns whether the object belongs to a subtree of the input node::
Expand Down
25 changes: 20 additions & 5 deletions waflib/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ def split_argfile(self, cmd):
"""
return ([cmd[0]], [self.quote_flag(x) for x in cmd[1:]])

def should_split(self, cmd):
"""return True if this command needs splitting for argument length"""
if isinstance(cmd, str):
return False
if Utils.is_win32 and len(repr(cmd)) >= 8192:
return True
if sys.platform.startswith("cygwin") and len(repr(cmd)) > 20000:
return True
return len(repr(cmd)) > 200000

def exec_command(self, cmd, **kw):
"""
Wrapper for :py:meth:`waflib.Context.Context.exec_command`.
Expand Down Expand Up @@ -302,15 +312,15 @@ def exec_command(self, cmd, **kw):

# workaround for command line length limit:
# http://support.microsoft.com/kb/830473
if not isinstance(cmd, str) and (len(repr(cmd)) >= 8192 if Utils.is_win32 else len(cmd) > 200000):
if self.should_split(cmd):
cmd, args = self.split_argfile(cmd)
try:
(fd, tmp) = tempfile.mkstemp()
os.write(fd, '\r\n'.join(args).encode())
os.write(fd, '\r\n'.join(args[1:]).encode())
os.close(fd)
if Logs.verbose:
Logs.debug('argfile: @%r -> %r', tmp, args)
return self.generator.bld.exec_command(cmd + ['@' + tmp], **kw)
return self.generator.bld.exec_command(cmd + args[:1] + ['@' + tmp], **kw)
finally:
try:
os.remove(tmp)
Expand Down Expand Up @@ -446,10 +456,15 @@ def format_error(self):
elif not self.hasrun:
return 'task in %r was not executed for some reason: %r' % (name, self)
elif self.hasrun == CRASHED:
if isinstance(msg, str):
txt = msg
else:
txt = ' '.join(repr(x) if ' ' in x else x for x in msg)

try:
return ' -> task in %r failed with exit status %r%s' % (name, self.err_code, msg)
return ' -> task in %r failed (exit status %r): %r\n%s' % (name, self.err_code, self, txt)
except AttributeError:
return ' -> task in %r failed%s' % (name, msg)
return ' -> task in %r failed: %r\n%s' % (name, self, txt)
elif self.hasrun == MISSING:
return ' -> missing files in %r%s' % (name, msg)
elif self.hasrun == CANCELED:
Expand Down
4 changes: 2 additions & 2 deletions waflib/Tools/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def c_hook(self, node):

class c(Task.Task):
"Compiles C files into object files"
run_str = '${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
run_str = '${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].relpath()} ${CPPFLAGS}'
vars = ['CCDEPS'] # unused variable to depend on, just in case
ext_in = ['.h'] # set the build order easily by using ext_out=['.h']
scan = c_preproc.scan

class cprogram(link_task):
"Links object files into c programs"
run_str = '${LINK_CC} ${LINKFLAGS} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB} ${LDFLAGS}'
run_str = '${LINK_CC} ${LINKFLAGS} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].relpath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB} ${LDFLAGS}'
ext_out = ['.bin']
vars = ['LINKDEPS']
inst_to = '${BINDIR}'
Expand Down
2 changes: 1 addition & 1 deletion waflib/Tools/c_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ def get_cc_version(conf, cc, gcc=False, icc=False, clang=False):
cmd = cc + ['-dM', '-E', '-']
env = conf.env.env or None
try:
out, err = conf.cmd_and_log(cmd, output=0, input='\n'.encode(), env=env)
out, err = conf.cmd_and_log(cmd, output=0, stdin=open('/dev/null','r'), env=env)
except Errors.WafError:
conf.fatal('Could not determine the compiler version %r' % cmd)

Expand Down
4 changes: 2 additions & 2 deletions waflib/Tools/cxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def cxx_hook(self, node):

class cxx(Task.Task):
"Compiles C++ files into object files"
run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT[0].relpath()} ${CPPFLAGS}'
vars = ['CXXDEPS'] # unused variable to depend on, just in case
ext_in = ['.h'] # set the build order easily by using ext_out=['.h']
scan = c_preproc.scan

class cxxprogram(link_task):
"Links object files into c++ programs"
run_str = '${LINK_CXX} ${LINKFLAGS} ${CXXLNK_SRC_F}${SRC} ${CXXLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB} ${LDFLAGS}'
run_str = '${LINK_CXX} ${LINKFLAGS} ${CXXLNK_SRC_F}${SRC} ${CXXLNK_TGT_F}${TGT[0].relpath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB} ${LDFLAGS}'
vars = ['LINKDEPS']
ext_out = ['.bin']
inst_to = '${BINDIR}'
Expand Down
5 changes: 4 additions & 1 deletion waflib/Tools/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def gcc_modifier_win32(conf):
# Auto-import is enabled by default even without this option,
# but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
# that the linker emits otherwise.
v.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])
import sys
if sys.platform != "cygwin":
# disabled on cygwin as it breaks build with arm cross compiler
v.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])

@conf
def gcc_modifier_cygwin(conf):
Expand Down
5 changes: 4 additions & 1 deletion waflib/Tools/gxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def gxx_modifier_win32(conf):
# Auto-import is enabled by default even without this option,
# but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
# that the linker emits otherwise.
v.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])
import sys
if sys.platform != "cygwin":
# disabled on cygwin as it breaks build with arm cross compiler
v.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])

@conf
def gxx_modifier_cygwin(conf):
Expand Down
8 changes: 7 additions & 1 deletion waflib/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ class TimeoutExpired(Exception):
try:
from md5 import md5
except ImportError:
# never fail to enable fixes from another module
# never fail to enable potential fixes from another module
pass
else:
try:
md5().digest()
except ValueError:
# Fips? #2213
from hashlib import sha1 as md5

try:
import threading
Expand Down
2 changes: 1 addition & 1 deletion waflib/extras/gccdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def post_run(self):
node = path_to_node(path, x, cached_nodes)

if not node:
raise ValueError('could not find %r for %r' % (x, self))
continue
if id(node) == id(self.inputs[0]):
# ignore the source file, it is already in the dependencies
# this way, successful config tests may be retrieved from the cache
Expand Down
2 changes: 1 addition & 1 deletion wscript
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To add a tool that does not exist in the folder compat15, pass an absolute path:

from __future__ import with_statement

VERSION="2.0.8"
VERSION="2.0.9"
APPNAME='waf'
REVISION=''

Expand Down