Revert bug 1284816, bug 1341967, bug 1336153 to postpone bustage on non-x86 archs. diff --git browser/confvars.sh browser/confvars.sh index d8dcd99c2757..740d9d3e5fcf 100755 --- browser/confvars.sh +++ browser/confvars.sh @@ -30,6 +30,7 @@ if test "$OS_ARCH" = "WINNT"; then fi fi +MOZ_RUST_MP4PARSE=1 if test "$NIGHTLY_BUILD"; then MOZ_RUST_URLPARSE=1 fi diff --git build/moz.configure/rust.configure build/moz.configure/rust.configure index 267d989f1597..f709820e60ae 100644 --- build/moz.configure/rust.configure +++ build/moz.configure/rust.configure @@ -4,10 +4,20 @@ # 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/. -# Rust is required by `rust_compiler` below. We allow_missing here -# to propagate failures to the better error message there. -rustc = check_prog('RUSTC', ['rustc'], allow_missing=True) -cargo = check_prog('CARGO', ['cargo'], allow_missing=True) +option('--disable-rust', help='Don\'t include Rust language sources') + +@depends('--enable-rust') +def rust_compiler_names(value): + if value: + return ['rustc'] + +@depends('--enable-rust') +def cargo_binary_names(value): + if value: + return ['cargo'] + +rustc = check_prog('RUSTC', rust_compiler_names, allow_missing=True) +cargo = check_prog('CARGO', cargo_binary_names, allow_missing=True) @depends_if(rustc) @checking('rustc version', lambda info: info.version) @@ -43,9 +53,12 @@ def cargo_info(cargo): version=Version(version), ) -@depends(rustc_info, cargo_info) +@depends('--enable-rust', rustc_info, cargo_info) @imports(_from='textwrap', _import='dedent') -def rust_compiler(rustc_info, cargo_info): +def rust_compiler(value, rustc_info, cargo_info): + if not value: + return None + if not rustc_info: die(dedent('''\ Rust compiler not found. @@ -97,6 +110,9 @@ def rust_compiler(rustc_info, cargo_info): return True +set_define('MOZ_RUST', rust_compiler) +set_config('MOZ_RUST', rust_compiler) + @template def rust_triple_alias(host_or_target): """Template defining the alias used for rustc's --target flag. @@ -227,7 +243,8 @@ set_config('RUST_HOST_TARGET', rust_host_triple) @depends(rust_target_triple) def rust_target_env_name(triple): - return triple.upper().replace('-','_') + if triple: + return triple.upper().replace('-','_') # We need this to form various Cargo environment variables, as there is no # uppercase function in make, and we don't want to shell out just for @@ -235,5 +252,6 @@ def rust_target_env_name(triple): set_config('RUST_TARGET_ENV_NAME', rust_target_env_name) # Until we remove all the other Rust checks in old-configure. +add_old_configure_assignment('MOZ_RUST', rust_compiler) add_old_configure_assignment('RUSTC', rustc) add_old_configure_assignment('RUST_TARGET', rust_target_triple) diff --git config/rules.mk config/rules.mk index 94cc5556e3d0..7b143ebc5146 100644 --- config/rules.mk +++ config/rules.mk @@ -900,6 +900,7 @@ endif $(foreach file,$(DUMP_SYMS_TARGETS),$(eval $(call syms_template,$(file),$(file)_syms.track))) +ifdef MOZ_RUST cargo_host_flag := --target=$(RUST_HOST_TARGET) cargo_target_flag := --target=$(RUST_TARGET) @@ -1055,6 +1056,7 @@ force-cargo-host-program-build: $(HOST_RUST_PROGRAMS): force-cargo-host-program-build endif # HOST_RUST_PROGRAMS +endif # MOZ_RUST $(SOBJS): $(REPORT_BUILD) diff --git dom/media/MediaPrefs.h dom/media/MediaPrefs.h index 4dcc659222a4..559334d89fd1 100644 --- dom/media/MediaPrefs.h +++ dom/media/MediaPrefs.h @@ -183,7 +183,7 @@ private: DECL_MEDIA_PREF("media.ogg.flac.enabled", FlacInOgg, bool, false); DECL_MEDIA_PREF("media.flac.enabled", FlacEnabled, bool, true); -#if !defined(RELEASE_OR_BETA) +#if defined(MOZ_RUST_MP4PARSE) && !defined(RELEASE_OR_BETA) DECL_MEDIA_PREF("media.rust.test_mode", RustTestMode, bool, false); #endif diff --git dom/media/gtest/moz.build dom/media/gtest/moz.build index c66ac4a9437f..e2203c0a4321 100644 --- dom/media/gtest/moz.build +++ dom/media/gtest/moz.build @@ -22,7 +22,6 @@ UNIFIED_SOURCES += [ 'TestMozPromise.cpp', 'TestMP3Demuxer.cpp', 'TestMP4Demuxer.cpp', - 'TestRust.cpp', 'TestTrackEncoder.cpp', 'TestVideoSegment.cpp', 'TestVideoUtils.cpp', @@ -36,6 +35,9 @@ if CONFIG['MOZ_WEBM_ENCODER']: 'TestWebMWriter.cpp', ] +if CONFIG['MOZ_RUST']: + UNIFIED_SOURCES += ['TestRust.cpp',] + TEST_HARNESS_FILES.gtest += [ '../test/gizmo-frag.mp4', '../test/gizmo.mp4', diff --git media/libcubeb/src/moz.build media/libcubeb/src/moz.build index c65b53b80f63..8953f646e831 100644 --- media/libcubeb/src/moz.build +++ media/libcubeb/src/moz.build @@ -32,7 +32,8 @@ if CONFIG['MOZ_PULSEAUDIO']: 'cubeb_pulse.c', ] DEFINES['USE_PULSE'] = True - DEFINES['USE_PULSE_RUST'] = True + if CONFIG['MOZ_RUST']: + DEFINES['USE_PULSE_RUST'] = True if CONFIG['MOZ_JACK']: SOURCES += [ diff --git media/libstagefright/binding/DecoderData.cpp media/libstagefright/binding/DecoderData.cpp index 109ea329d154..a06e533b1e62 100644 --- media/libstagefright/binding/DecoderData.cpp +++ media/libstagefright/binding/DecoderData.cpp @@ -13,9 +13,11 @@ #include "mozilla/ArrayUtils.h" #include "include/ESDS.h" +#ifdef MOZ_RUST_MP4PARSE // OpusDecoder header is really needed only by MP4 in rust #include "OpusDecoder.h" #include "mp4parse.h" +#endif // MOZ_RUST_MP4PARSE using namespace stagefright; using mozilla::media::TimeUnit; @@ -177,6 +179,7 @@ MP4VideoInfo::Update(const MetaData* aMetaData, const char* aMimeType) FindData(aMetaData, kKeyAVCC, mExtraData); } +#ifdef MOZ_RUST_MP4PARSE static void UpdateTrackProtectedInfo(mozilla::TrackInfo& aConfig, const mp4parse_sinf_info& aSinf) @@ -263,6 +266,7 @@ MP4VideoInfo::Update(const mp4parse_track_info* track, mExtraData->AppendElements(video->extra_data.data, video->extra_data.length); } } +#endif // MOZ_RUST_MP4PARSE bool MP4VideoInfo::IsValid() const diff --git media/libstagefright/binding/MP4Metadata.cpp media/libstagefright/binding/MP4Metadata.cpp index 5c3810d99a38..5d14dfd8b8a9 100644 --- media/libstagefright/binding/MP4Metadata.cpp +++ media/libstagefright/binding/MP4Metadata.cpp @@ -20,14 +20,18 @@ #include "mp4_demuxer/MP4Metadata.h" #include "mp4_demuxer/Stream.h" #include "MediaPrefs.h" +#ifdef MOZ_RUST_MP4PARSE #include "mp4parse.h" +#endif // MOZ_RUST_MP4PARSE #include #include #include +#ifdef MOZ_RUST_MP4PARSE struct FreeMP4Parser { void operator()(mp4parse_parser* aPtr) { mp4parse_free(aPtr); } }; +#endif // MOZ_RUST_MP4PARSE using namespace stagefright; using mozilla::media::TimeUnit; @@ -105,6 +109,7 @@ private: bool mCanSeek; }; +#ifdef MOZ_RUST_MP4PARSE // Wrap an mp4_demuxer::Stream to remember the read offset. class RustStreamAdaptor { @@ -151,6 +156,7 @@ private: RustStreamAdaptor mRustSource; mozilla::UniquePtr mRustParser; }; +#endif // MOZ_RUST_MP4PARSE class IndiceWrapperStagefright : public IndiceWrapper { public: @@ -187,6 +193,7 @@ IndiceWrapperStagefright::GetIndice(size_t aIndex, Index::Indice& aIndice) const return true; } +#ifdef MOZ_RUST_MP4PARSE // the owner of mIndice is rust mp4 paser, so lifetime of this class // SHOULD NOT longer than rust parser. class IndiceWrapperRust : public IndiceWrapper @@ -232,9 +239,11 @@ IndiceWrapperRust::GetIndice(size_t aIndex, Index::Indice& aIndice) const aIndice.sync = indice->sync; return true; } +#endif // MOZ_RUST_MP4PARSE MP4Metadata::MP4Metadata(Stream* aSource) : mStagefright(MakeUnique(aSource)) +#ifdef MOZ_RUST_MP4PARSE , mRust(MakeUnique(aSource)) , mPreferRust(MediaPrefs::EnableRustMP4Parser()) , mReportedAudioTrackTelemetry(false) @@ -242,6 +251,7 @@ MP4Metadata::MP4Metadata(Stream* aSource) #ifndef RELEASE_OR_BETA , mRustTestMode(MediaPrefs::RustTestMode()) #endif +#endif // MOZ_RUST_MP4PARSE { } @@ -274,8 +284,11 @@ MP4Metadata::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const MP4Metadata::ResultAndTrackCount numTracks = mStagefright->GetNumberTracks(aType); +#ifdef MOZ_RUST_MP4PARSE if (!mRust) { +#endif // MOZ_RUST_MP4PARSE return numTracks; +#ifdef MOZ_RUST_MP4PARSE } MP4Metadata::ResultAndTrackCount numTracksRust = @@ -350,8 +363,10 @@ MP4Metadata::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const // Same non-error numbers, just return any. // (Choosing Rust here, in case it carries a warning, we'd want to know that.) return numTracksRust; +#endif // MOZ_RUST_MP4PARSE } +#ifdef MOZ_RUST_MP4PARSE bool MP4Metadata::ShouldPreferRust() const { if (!mRust) { return false; @@ -389,6 +404,7 @@ bool MP4Metadata::ShouldPreferRust() const { // Otherwise, fall back. return false; } +#endif // MOZ_RUST_MP4PARSE static const char* GetDifferentField(const mozilla::TrackInfo& info, @@ -443,6 +459,7 @@ MP4Metadata::GetTrackInfo(mozilla::TrackInfo::TrackType aType, MP4Metadata::ResultAndTrackInfo info = mStagefright->GetTrackInfo(aType, aTrackNumber); +#ifdef MOZ_RUST_MP4PARSE if (!mRust) { return info; } @@ -514,6 +531,7 @@ MP4Metadata::GetTrackInfo(mozilla::TrackInfo::TrackType aType, if (mPreferRust) { return infoRust; } +#endif // MOZ_RUST_MP4PARSE return info; } @@ -528,6 +546,7 @@ MP4Metadata::ResultAndCryptoFile MP4Metadata::Crypto() const { MP4Metadata::ResultAndCryptoFile crypto = mStagefright->Crypto(); +#ifdef MOZ_RUST_MP4PARSE MP4Metadata::ResultAndCryptoFile rustCrypto = mRust->Crypto(); #ifndef RELEASE_OR_BETA @@ -548,6 +567,7 @@ MP4Metadata::Crypto() const if (mPreferRust) { return rustCrypto; } +#endif // MOZ_RUST_MP4PARSE return crypto; } @@ -556,17 +576,22 @@ MP4Metadata::ResultAndIndice MP4Metadata::GetTrackIndice(mozilla::TrackID aTrackID) { FallibleTArray indiceSF; +#ifdef MOZ_RUST_MP4PARSE if (!mPreferRust #ifndef RELEASE_OR_BETA || mRustTestMode #endif ) { +#endif // MOZ_RUST_MP4PARSE MediaResult rv = mStagefright->ReadTrackIndex(indiceSF, aTrackID); if (NS_FAILED(rv)) { return {Move(rv), nullptr}; } +#ifdef MOZ_RUST_MP4PARSE } +#endif // MOZ_RUST_MP4PARSE +#ifdef MOZ_RUST_MP4PARSE mp4parse_byte_data indiceRust = {}; if (mPreferRust #ifndef RELEASE_OR_BETA @@ -592,13 +617,18 @@ MP4Metadata::GetTrackIndice(mozilla::TrackID aTrackID) } } #endif +#endif // MOZ_RUST_MP4PARSE UniquePtr indice; +#ifdef MOZ_RUST_MP4PARSE if (mPreferRust) { indice = mozilla::MakeUnique(indiceRust); } else { +#endif // MOZ_RUST_MP4PARSE indice = mozilla::MakeUnique(indiceSF); +#ifdef MOZ_RUST_MP4PARSE } +#endif // MOZ_RUST_MP4PARSE return {NS_OK, Move(indice)}; } @@ -856,6 +886,7 @@ MP4MetadataStagefright::Metadata(Stream* aSource) return {NS_OK, Move(buffer)}; } +#ifdef MOZ_RUST_MP4PARSE bool RustStreamAdaptor::Read(uint8_t* buffer, uintptr_t size, size_t* bytes_read) { @@ -1152,5 +1183,6 @@ MP4MetadataRust::Metadata(Stream* aSource) MOZ_ASSERT(false, "Not yet implemented"); return {NS_ERROR_NOT_IMPLEMENTED, nullptr}; } +#endif // MOZ_RUST_MP4PARSE } // namespace mp4_demuxer diff --git media/libstagefright/binding/include/mp4_demuxer/DecoderData.h media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index 3cd4b7c142f4..dc25ddf03b10 100644 --- media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -19,11 +19,13 @@ namespace stagefright class MetaData; } +#ifdef MOZ_RUST_MP4PARSE extern "C" { typedef struct mp4parse_track_info mp4parse_track_info; typedef struct mp4parse_track_audio_info mp4parse_track_audio_info; typedef struct mp4parse_track_video_info mp4parse_track_video_info; } +#endif // MOZ_RUST_MP4PARSE namespace mp4_demuxer { @@ -71,8 +73,10 @@ public: void Update(const stagefright::MetaData* aMetaData, const char* aMimeType); +#ifdef MOZ_RUST_MP4PARSE void Update(const mp4parse_track_info* track, const mp4parse_track_audio_info* audio); +#endif // MOZ_RUST_MP4PARSE virtual bool IsValid() const override; }; @@ -85,8 +89,10 @@ public: void Update(const stagefright::MetaData* aMetaData, const char* aMimeType); +#ifdef MOZ_RUST_MP4PARSE void Update(const mp4parse_track_info* track, const mp4parse_track_video_info* video); +#endif // MOZ_RUST_MP4PARSE virtual bool IsValid() const override; }; diff --git media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h index 492c9c1c1bc3..e16dbbd1155e 100644 --- media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h +++ media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h @@ -13,7 +13,9 @@ #include "MediaInfo.h" #include "MediaResult.h" #include "Stream.h" +#ifdef MOZ_RUST_MP4PARSE #include "mp4parse.h" +#endif // MOZ_RUST_MP4PARSE namespace mp4_demuxer { @@ -82,6 +84,7 @@ public: private: UniquePtr mStagefright; +#ifdef MOZ_RUST_MP4PARSE UniquePtr mRust; mutable bool mPreferRust; mutable bool mReportedAudioTrackTelemetry; @@ -90,6 +93,7 @@ private: mutable bool mRustTestMode; #endif bool ShouldPreferRust() const; +#endif // MOZ_RUST_MP4PARSE }; } // namespace mp4_demuxer diff --git media/libstagefright/gtest/moz.build media/libstagefright/gtest/moz.build index be4d56fc93f7..66fdd365f8f3 100644 --- media/libstagefright/gtest/moz.build +++ media/libstagefright/gtest/moz.build @@ -38,12 +38,13 @@ TEST_HARNESS_FILES.gtest += [ 'test_case_1351094.mp4', ] -UNIFIED_SOURCES += ['TestMP4Rust.cpp',] -TEST_HARNESS_FILES.gtest += [ - '../../../dom/media/test/street.mp4', -] -LOCAL_INCLUDES += [ - '../binding/include', -] +if CONFIG['MOZ_RUST']: + UNIFIED_SOURCES += ['TestMP4Rust.cpp',] + TEST_HARNESS_FILES.gtest += [ + '../../../dom/media/test/street.mp4', + ] + LOCAL_INCLUDES += [ + '../binding/include', + ] FINAL_LIBRARY = 'xul-gtest' diff --git media/libstagefright/moz.build media/libstagefright/moz.build index af5d1194d621..6725a0179989 100644 --- media/libstagefright/moz.build +++ media/libstagefright/moz.build @@ -83,9 +83,10 @@ SOURCES += [ 'system/core/libutils/VectorImpl.cpp', ] -EXPORTS += [ - 'binding/include/mp4parse.h', -] +if CONFIG['MOZ_RUST']: + EXPORTS += [ + 'binding/include/mp4parse.h', + ] UNIFIED_SOURCES += [ 'binding/Adts.cpp', diff --git mobile/android/confvars.sh mobile/android/confvars.sh index e79b6f5c0707..eb62763acaf7 100644 --- mobile/android/confvars.sh +++ mobile/android/confvars.sh @@ -30,6 +30,8 @@ MOZ_XULRUNNER= MOZ_CAPTURE=1 MOZ_RAW=1 +MOZ_RUST_MP4PARSE=1 + # use custom widget for html:select MOZ_USE_NATIVE_POPUP_WINDOWS=1 diff --git netwerk/base/moz.build netwerk/base/moz.build index 61d022a9660e..e5ca1d77d859 100644 --- netwerk/base/moz.build +++ netwerk/base/moz.build @@ -256,7 +256,7 @@ UNIFIED_SOURCES += [ 'TLSServerSocket.cpp', ] -if CONFIG['MOZ_RUST_URLPARSE']: +if CONFIG['MOZ_RUST'] and CONFIG['MOZ_RUST_URLPARSE']: EXPORTS.mozilla.net += [ 'RustURL.h' ] UNIFIED_SOURCES += [ 'RustURL.cpp' ] diff --git netwerk/base/nsStandardURL.cpp netwerk/base/nsStandardURL.cpp index 608b918a4ecf..20bcdeb34ab8 100644 --- netwerk/base/nsStandardURL.cpp +++ netwerk/base/nsStandardURL.cpp @@ -858,6 +858,7 @@ nsStandardURL::BuildNormalizedSpec(const char *spec) if (!SegmentIs(spec, mScheme, "resource") && !SegmentIs(spec, mScheme, "chrome")) { nsAutoCString ipString; +#ifdef MOZ_RUST if (encHost.Length() > 0 && encHost.First() == '[' && encHost.Last() == ']' && ValidIPv6orHostname(encHost.get(), encHost.Length())) { @@ -866,7 +867,9 @@ nsStandardURL::BuildNormalizedSpec(const char *spec) return rv; } encHost = ipString; - } else if (NS_SUCCEEDED(NormalizeIPv4(encHost, ipString))) { + } else +#endif + if (NS_SUCCEEDED(NormalizeIPv4(encHost, ipString))) { encHost = ipString; } } @@ -2112,6 +2115,7 @@ nsStandardURL::SetHost(const nsACString &input) if (!SegmentIs(mScheme, "resource") && !SegmentIs(mScheme, "chrome")) { nsAutoCString ipString; +#ifdef MOZ_RUST if (hostBuf.Length() > 0 && hostBuf.First() == '[' && hostBuf.Last() == ']' && ValidIPv6orHostname(hostBuf.get(), hostBuf.Length())) { @@ -2120,7 +2124,9 @@ nsStandardURL::SetHost(const nsACString &input) return rv; } hostBuf = ipString; - } else if (NS_SUCCEEDED(NormalizeIPv4(hostBuf, ipString))) { + } else +#endif + if (NS_SUCCEEDED(NormalizeIPv4(hostBuf, ipString))) { hostBuf = ipString; } } diff --git old-configure.in old-configure.in index 717a94fcc692..54b29d737cc1 100644 --- old-configure.in +++ old-configure.in @@ -2330,9 +2330,14 @@ if test -n "$MOZ_MULET"; then fi # Propagate feature switches for code written in rust from confvars.sh -if test -n "$MOZ_RUST_URLPARSE"; then - AC_DEFINE(MOZ_RUST_URLPARSE) - AC_SUBST(MOZ_RUST_URLPARSE) +if test -n "$MOZ_RUST"; then + if test -n "$MOZ_RUST_MP4PARSE"; then + AC_DEFINE(MOZ_RUST_MP4PARSE) + fi + if test -n "$MOZ_RUST_URLPARSE"; then + AC_DEFINE(MOZ_RUST_URLPARSE) + AC_SUBST(MOZ_RUST_URLPARSE) + fi fi AC_SUBST(MOZ_PHOENIX) diff --git toolkit/components/telemetry/Histograms.json toolkit/components/telemetry/Histograms.json index 061c55f6a5b6..e49dfd176952 100644 --- toolkit/components/telemetry/Histograms.json +++ toolkit/components/telemetry/Histograms.json @@ -8320,7 +8320,8 @@ "expires_in_version": "60", "kind": "boolean", "bug_numbers": [1220885], - "description": "Whether the rust mp4 demuxer successfully parsed a stream segment." + "description": "Whether the rust mp4 demuxer successfully parsed a stream segment.", + "cpp_guard": "MOZ_RUST_MP4PARSE" }, "MEDIA_RUST_MP4PARSE_ERROR_CODE": { "record_in_processes": ["main", "content"], @@ -8329,7 +8330,8 @@ "kind": "enumerated", "n_values": 32, "bug_numbers": [1238420], - "description": "The error code reported when an MP4 parse attempt has failed.0 = OK, 1 = bad argument, 2 = invalid data, 3 = unsupported, 4 = unexpected end of file, 5 = read error." + "description": "The error code reported when an MP4 parse attempt has failed.0 = OK, 1 = bad argument, 2 = invalid data, 3 = unsupported, 4 = unexpected end of file, 5 = read error.", + "cpp_guard": "MOZ_RUST_MP4PARSE" }, "MEDIA_RUST_MP4PARSE_TRACK_MATCH_AUDIO": { "record_in_processes": ["main", "content"], @@ -8337,7 +8339,8 @@ "expires_in_version": "60", "kind": "boolean", "bug_numbers": [1231169], - "description": "Whether rust and stagefight mp4 parser audio track results match." + "description": "Whether rust and stagefight mp4 parser audio track results match.", + "cpp_guard": "MOZ_RUST_MP4PARSE" }, "MEDIA_RUST_MP4PARSE_TRACK_MATCH_VIDEO": { "record_in_processes": ["main", "content"], @@ -8345,7 +8348,8 @@ "expires_in_version": "60", "kind": "boolean", "bug_numbers": [1231169], - "description": "Whether rust and stagefight mp4 parser video track results match." + "description": "Whether rust and stagefight mp4 parser video track results match.", + "cpp_guard": "MOZ_RUST_MP4PARSE" }, "MEDIA_WMF_DECODE_ERROR": { "record_in_processes": ["main", "content", "gpu"], diff --git toolkit/library/gtest/moz.build toolkit/library/gtest/moz.build index 69a8fb1f4893..c684f48e456e 100644 --- toolkit/library/gtest/moz.build +++ toolkit/library/gtest/moz.build @@ -7,7 +7,6 @@ FINAL_TARGET = 'dist/bin/gtest' USE_LIBS += [ - 'gkrust-gtest', 'static:xul', # xul-gtest is an intermediate static library. It is used as FINAL_TARGET # for gtest code. @@ -21,6 +20,11 @@ USE_LIBS += [ # before StaticXULComponentStart. Libxul('xul-gtest-real') +if CONFIG['MOZ_RUST']: + USE_LIBS += [ + 'gkrust-gtest', + ] + DIRS += [ 'static', ] diff --git toolkit/library/moz.build toolkit/library/moz.build index 650f6eaba980..191e90ceb09a 100644 --- toolkit/library/moz.build +++ toolkit/library/moz.build @@ -63,7 +63,7 @@ def Libxul(name): # This option should go away in bug 1290972, but we need to wait until # Rust 1.12 has been released. - if CONFIG['OS_ARCH'] == 'Darwin': + if CONFIG['MOZ_RUST'] and CONFIG['OS_ARCH'] == 'Darwin': LDFLAGS += ['-Wl,-no_compact_unwind'] Libxul('xul') @@ -343,4 +343,5 @@ USE_LIBS += ['StaticXULComponentsEnd'] # The above library needs to be last for C++ purposes. This library, # however, is entirely composed of Rust code, and needs to come after # all the C++ code so any possible C++ -> Rust calls can be resolved. -USE_LIBS += ['gkrust'] +if CONFIG['MOZ_RUST']: + USE_LIBS += ['gkrust'] diff --git toolkit/moz.configure toolkit/moz.configure index ac9d123224ce..e90da70f0fa5 100644 --- toolkit/moz.configure +++ toolkit/moz.configure @@ -88,8 +88,7 @@ include('../js/moz.configure') # Rust # ============================================================== -include('../build/moz.configure/rust.configure', - when='--enable-compile-environment') +include('../build/moz.configure/rust.configure') # L10N @@ -623,13 +622,13 @@ id_and_secret_keyfile('Leanplum SDK') option('--enable-stylo', nargs='?', choices=('build',), help='Include Stylo in the build and/or enable it at runtime') -@depends('--enable-stylo') -def stylo_config(value): +@depends('--enable-stylo', '--enable-rust') +def stylo_config(value, rust_enabled): build_stylo = None enable_stylo = None # The default is to not build Stylo at all. - if value.origin == 'default': + if not rust_enabled or value.origin == 'default': pass elif value == 'build': build_stylo = True @@ -769,12 +768,14 @@ set_config('SERVO_TARGET_DIR', servo_target_dir) option('--enable-webrender', nargs='?', choices=('build',), help='Include WebRender in the build and/or enable it at runtime') -@depends('--enable-webrender', milestone) -def webrender(value, milestone): +@depends('--enable-webrender', '--enable-rust', milestone) +def webrender(value, rust_enabled, milestone): build_webrender = None enable_webrender = None - if value.origin == 'default': + if not rust_enabled: + pass + elif value.origin == 'default': # if nothing is specified, default to just building on Nightly build_webrender = milestone.is_nightly elif value == 'build': diff --git toolkit/toolkit.mozbuild toolkit/toolkit.mozbuild index b845aab48023..9215afc6dd2d 100644 --- toolkit/toolkit.mozbuild +++ toolkit/toolkit.mozbuild @@ -133,16 +133,23 @@ if CONFIG['MOZ_PREF_EXTENSIONS']: DIRS += [ '/devtools', - '/toolkit/library', - '/toolkit/library/gtest/rust', - '/toolkit/library/rust', - '/toolkit/library/StaticXULComponentsEnd', '/services', '/startupcache', '/js/ductwork/debugger', '/other-licenses/snappy', ] +if CONFIG['MOZ_RUST']: + DIRS += [ + '/toolkit/library/gtest/rust', + '/toolkit/library/rust', + ] + +DIRS += [ + '/toolkit/library/StaticXULComponentsEnd', + '/toolkit/library', +] + if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: DIRS += ['/toolkit/system/gnome'] diff --git toolkit/xre/nsAppRunner.cpp toolkit/xre/nsAppRunner.cpp index 667c2eb1b365..6fb6cf102baa 100644 --- toolkit/xre/nsAppRunner.cpp +++ toolkit/xre/nsAppRunner.cpp @@ -227,11 +227,13 @@ extern uint32_t gRestartMode; extern void InstallSignalHandlers(const char *ProgramName); +#ifdef MOZ_RUST // This workaround is fixed in Rust 1.19. For details, see bug 1358151. // Implementation in toolkit/library/rust/shared/lib.rs extern "C" { void rust_init_please_remove_this_after_updating_rust_1_19(); } +#endif #define FILE_COMPATIBILITY_INFO NS_LITERAL_CSTRING("compatibility.ini") #define FILE_INVALIDATE_CACHES NS_LITERAL_CSTRING(".purgecaches") @@ -3122,8 +3124,10 @@ XREMain::XRE_mainInit(bool* aExitFlag) return 1; *aExitFlag = false; +#ifdef MOZ_RUST // This workaround is fixed in Rust 1.19. For details, see bug 1358151. rust_init_please_remove_this_after_updating_rust_1_19(); +#endif atexit(UnexpectedExit); auto expectedShutdown = mozilla::MakeScopeExit([&] { diff --git xpcom/base/nsDebugImpl.cpp xpcom/base/nsDebugImpl.cpp index e6bb623c258b..c49d61dce605 100644 --- xpcom/base/nsDebugImpl.cpp +++ xpcom/base/nsDebugImpl.cpp @@ -148,14 +148,20 @@ nsDebugImpl::Abort(const char* aFile, int32_t aLine) return NS_OK; } +#ifdef MOZ_RUST // From toolkit/library/rust/lib.rs extern "C" void intentional_panic(const char* message); +#endif NS_IMETHODIMP nsDebugImpl::RustPanic(const char* aMessage) { +#ifdef MOZ_RUST intentional_panic(aMessage); return NS_OK; +#else + return NS_ERROR_NOT_IMPLEMENTED; +#endif } NS_IMETHODIMP diff --git xpcom/rust/nsstring/gtest/moz.build xpcom/rust/nsstring/gtest/moz.build index 197411678815..5bed9e57e57d 100644 --- xpcom/rust/nsstring/gtest/moz.build +++ xpcom/rust/nsstring/gtest/moz.build @@ -4,8 +4,9 @@ # 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/. -UNIFIED_SOURCES += [ - 'Test.cpp' -] +if CONFIG['MOZ_RUST']: + UNIFIED_SOURCES += [ + 'Test.cpp' + ] FINAL_LIBRARY = 'xul-gtest'