Skip to content
This repository has been archived by the owner on Jul 3, 2018. It is now read-only.

Commit

Permalink
Bug 1262155 - Use moz.build instead of libffi's build system. r=ted,g…
Browse files Browse the repository at this point in the history
…landium

MozReview-Commit-ID: 3wobNk0HDU5
  • Loading branch information
chmanchester committed Aug 8, 2016
1 parent 07b0b7c commit 6736329
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 100 deletions.
1 change: 0 additions & 1 deletion aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/icu.m4)dnl
builtin(include, build/autoconf/ffi.m4)dnl
builtin(include, build/autoconf/clang-plugin.m4)dnl
builtin(include, build/autoconf/alloc.m4)dnl
builtin(include, build/autoconf/ios.m4)dnl
Expand Down
2 changes: 0 additions & 2 deletions build/autoconf/alloc.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ for file in $MALLOC_HEADERS; do
fi
done
MOZ_CHECK_HEADERS(alloca.h)
AC_CHECK_FUNCS(strndup posix_memalign memalign)
AC_CHECK_FUNCS(malloc_usable_size)
Expand Down
74 changes: 0 additions & 74 deletions build/autoconf/ffi.m4

This file was deleted.

41 changes: 41 additions & 0 deletions build/moz.configure/ffi.configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

@depends(target)
def force_system_ffi(target):
# Pre-emptively move to system ffi for non-tier one platforms.
if target.cpu not in ('x86', 'x86_64', 'arm'):
return True

imply_option('--with-system-ffi', force_system_ffi, "target")

js_option('--with-system-ffi',
help='Use system libffi (located with pkgconfig)')

Expand All @@ -12,5 +20,38 @@ use_system_ffi = depends_if('--with-system-ffi')(lambda _: True)
system_ffi = pkg_check_modules('MOZ_FFI', 'libffi > 3.0.9',
when=use_system_ffi)

building_ffi = depends(system_ffi)(lambda v: not bool(v))

set_config('MOZ_SYSTEM_FFI', system_ffi)
add_old_configure_assignment('MOZ_SYSTEM_FFI', system_ffi)

# Target selection, based on ffi/configure.ac.
@depends_when(target, when=building_ffi)
def ffi_target(target):
if target.cpu not in ('x86', 'x86_64', 'arm'):
die('Building libffi from the tree is not supported on this platform. '
'Use --with-system-ffi instead.')

if target.os == 'WINNT':
target_dir = 'x86'
if target.cpu == 'x86_64':
target_name = 'X86_WIN64'
else:
target_name = 'X86_WIN32'
elif target.os == 'OSX':
target_dir = 'x86'
target_name = 'X86_DARWIN'
elif target.cpu == 'arm':
target_dir = 'arm'
target_name = 'ARM'
else:
target_dir = 'x86'
target_name = target.cpu.upper()

return namespace(
name=target_name,
dir=target_dir
)

set_config('FFI_TARGET', delayed_getattr(ffi_target, 'name'))
set_config('FFI_TARGET_DIR', delayed_getattr(ffi_target, 'dir'))
2 changes: 2 additions & 0 deletions build/moz.configure/headers.configure
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ building_linux = depends(target)(lambda target: target.kernel == 'Linux')

have_malloc = check_header('malloc.h')

check_header('alloca.h')

add_old_configure_assignment('HAVE_MALLOC_H', have_malloc)

check_headers(
Expand Down
14 changes: 7 additions & 7 deletions config/external/ffi/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

ifndef MOZ_SYSTEM_FFI

include $(topsrcdir)/config/config.mk

$(STATIC_LIBS):
$(MAKE) -C $(DEPTH)/js/src/ctypes/libffi

# libffi's assembly files want to be pre-processed, so we still use the libffi
# wrapper to combine the preprocessor and assembler stages.
# Bug 1299959 is on file to find a better way to do this in moz.build.
ifdef _MSC_VER
AS = $(topsrcdir)/js/src/ctypes/libffi/msvcc.sh
endif
99 changes: 91 additions & 8 deletions config/external/ffi/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,98 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Library('ffi')

if CONFIG['MOZ_SYSTEM_FFI']:
OS_LIBS += CONFIG['MOZ_FFI_LIBS']
else:
if CONFIG['_MSC_VER']:
prefix = 'lib'
else:
prefix = ''
USE_LIBS += [
'static:/js/src/ctypes/libffi/.libs/%sffi' % prefix,
FINAL_LIBRARY = 'js'
ALLOW_COMPILER_WARNINGS = True
NO_VISIBILITY_FLAGS = True

CONFIGURE_DEFINE_FILES += [
'../../../js/src/ctypes/libffi/fficonfig.h',
]
GENERATED_FILES += [
'../../../js/src/ctypes/libffi/include/ffi.h',
]
ffi_h = GENERATED_FILES['../../../js/src/ctypes/libffi/include/ffi.h']
ffi_h.script = 'subst_header.py'
ffi_h.inputs = ['../../../js/src/ctypes/libffi/include/ffi.h.in']

LOCAL_INCLUDES += [
'!/js/src/ctypes/libffi',
'!/js/src/ctypes/libffi/include',
'/js/src/ctypes/libffi/include',
'/js/src/ctypes/libffi/src/%s' % CONFIG['FFI_TARGET_DIR'],
]

DEFINES.update({
'TARGET': CONFIG['FFI_TARGET'],
CONFIG['FFI_TARGET']: True,
'FFI_NO_RAW_API': True,
'HAVE_AS_ASCII_PSEUDO_OP': True,
'HAVE_AS_STRING_PSEUDO_OP': True,
'HAVE_AS_X86_64_UNWIND_SECTION_TYPE': True,
})

if CONFIG['MOZ_DEBUG']:
DEFINES['FFI_DEBUG'] = True
if not CONFIG['MOZ_NO_DEBUG_RTL']:
DEFINES['USE_DEBUG_RTL'] = True
SOURCES += [
'/js/src/ctypes/libffi/src/debug.c',
]

if CONFIG['OS_TARGET'] not in ('WINNT', 'Darwin'):
DEFINES['HAVE_HIDDEN_VISIBILITY_ATTRIBUTE'] = True

if CONFIG['INTEL_ARCHITECTURE']:
DEFINES['HAVE_AS_X86_PCREL'] = True

# Don't bother setting EH_FRAME_FLAGS on Windows.
# Quoted defines confuse msvcc.sh, and the value isn't used there.
if CONFIG['OS_TARGET'] != 'WINNT':
if CONFIG['FFI_TARGET'] == 'ARM':
DEFINES['EH_FRAME_FLAGS'] = '"aw"'
else:
DEFINES['EH_FRAME_FLAGS'] = '"a"'

if CONFIG['CLANG_CL']:
ASFLAGS += ['-clang-cl']

# Common source files.
SOURCES += [
'/js/src/ctypes/libffi/src/closures.c',
'/js/src/ctypes/libffi/src/java_raw_api.c',
'/js/src/ctypes/libffi/src/prep_cif.c',
'/js/src/ctypes/libffi/src/raw_api.c',
'/js/src/ctypes/libffi/src/types.c',
]

# Per-platform sources and flags.
ffi_srcs = ()
if CONFIG['FFI_TARGET'] == 'ARM':
ffi_srcs = ('sysv.S', 'ffi.c')
if CONFIG['CLANG_CXX']:
ASFLAGS += ['-no-integrated-as']
elif CONFIG['FFI_TARGET'] == 'X86':
ffi_srcs = ('ffi.c', 'sysv.S', 'win32.S')
elif CONFIG['FFI_TARGET'] == 'X86_64':
ffi_srcs = ('ffi64.c', 'unix64.S', 'ffi.c', 'sysv.S')
elif CONFIG['FFI_TARGET'] == 'X86_WIN32':
ffi_srcs = ('ffi.c', 'win32.S')
elif CONFIG['FFI_TARGET'] == 'X86_WIN64':
ffi_srcs = ('ffi.c', 'win64.S')
ASFLAGS += ['-m64']
elif CONFIG['FFI_TARGET'] == 'X86_DARWIN':
DEFINES['FFI_MMAP_EXEC_WRIT'] = True
if CONFIG['OS_TEST'] != 'x86_64':
ffi_srcs = ('ffi.c', 'darwin.S', 'ffi64.c', 'darwin64.S',
'win32.S')
DEFINES['SYMBOL_UNDERSCORE'] = True
else:
ffi_srcs = ('ffi.c', 'darwin.S', 'ffi64.c', 'darwin64.S')

SOURCES += [
'/js/src/ctypes/libffi/src/%s/%s' % (CONFIG['FFI_TARGET_DIR'], s)
for s in sorted(ffi_srcs)
]
25 changes: 25 additions & 0 deletions config/external/ffi/subst_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Souce Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distibuted with this
# file, You can obtain one at http://mozilla.og/MPL/2.0/.

import sys
import buildconfig
from mozbuild.preprocessor import Preprocessor

def main(output, input_file):
pp = Preprocessor()
pp.context.update({
'FFI_EXEC_TRAMPOLINE_TABLE': '0',
'HAVE_LONG_DOUBLE': '0',
'TARGET': buildconfig.substs['FFI_TARGET'],
'VERSION': '',
})
pp.do_filter('substitution')
pp.setMarker(None)
pp.out = output
pp.do_include(input_file)

if __name__ == '__main__':
main(*sys.agv[1:])
1 change: 0 additions & 1 deletion js/src/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ builtin(include, ../../build/autoconf/arch.m4)dnl
builtin(include, ../../build/autoconf/android.m4)dnl
builtin(include, ../../build/autoconf/zlib.m4)dnl
builtin(include, ../../build/autoconf/icu.m4)dnl
builtin(include, ../../build/autoconf/ffi.m4)dnl
builtin(include, ../../build/autoconf/clang-plugin.m4)dnl
builtin(include, ../../build/autoconf/alloc.m4)dnl
builtin(include, ../../build/autoconf/jemalloc.m4)dnl
Expand Down
6 changes: 1 addition & 5 deletions js/src/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ if CONFIG['JS_HAS_CTYPES']:
if not CONFIG['MOZ_SYSTEM_FFI']:
LOCAL_INCLUDES += [
'!ctypes/libffi/include',
'ctypes/libffi/src/%s' % CONFIG['FFI_TARGET_DIR'],
]

if CONFIG['MOZ_VTUNE']:
Expand Down Expand Up @@ -637,11 +638,6 @@ else:
FORCE_STATIC_LIB = True
STATIC_LIBRARY_NAME = 'js_static'

if CONFIG['JS_HAS_CTYPES']:
USE_LIBS += [
'ffi',
]

if CONFIG['ENABLE_INTL_API']:
if not CONFIG['MOZ_ICU_DATA_ARCHIVE']:
USE_LIBS += [
Expand Down
1 change: 0 additions & 1 deletion js/src/old-configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2280,7 +2280,6 @@ AC_SUBST(JS_LIBRARY_NAME)
AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
AC_SUBST(JS_CONFIG_LIBS)

MOZ_SUBCONFIGURE_FFI()
MOZ_SUBCONFIGURE_JEMALLOC()

# Avoid using obsolete NSPR features
Expand Down
1 change: 0 additions & 1 deletion old-configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -6027,7 +6027,6 @@ AC_SUBST(NSS_DISABLE_LIBPKIX)
MOZ_CREATE_CONFIG_STATUS()

if test "$COMPILE_ENVIRONMENT"; then
MOZ_SUBCONFIGURE_FFI()
MOZ_SUBCONFIGURE_JEMALLOC()
fi

Expand Down

0 comments on commit 6736329

Please sign in to comment.