') + ')', 'gi');
if (regex.test(text)) {
found = true;
var frag = document.createDocumentFragment();
var parts = text.split(regex);
parts.forEach(function(part, i) {
if (i % 2 === 0) {
frag.appendChild(document.createTextNode(part));
} else {
var span = document.createElement('span');
span.className = 'userscript-highlight';
span.textContent = part;
frag.appendChild(span);
}
});
node.parentNode.replaceChild(frag, node);
}
});
} else if (node.nodeType === 1 && node.childNodes) { // element
var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];
if (!skipTags.includes(node.tagName)) {
Array.from(node.childNodes).forEach(highlight);
}
}
}
highlight(document.body);
// Re-highlight on dynamic content
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (node.nodeType === 1 || node.nodeType === 3) highlight(node);
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); }
})();
(function(){
try {
var __m = "*";
var __re = new RegExp('^' + ".*" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Strip utm_, fbclid, gclid, etc. from all links on page
(function() {
var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',
'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',
'ref', 'ref_src', 'source', 'medium', 'campaign'];
function cleanUrl(url) {
try {
var u = new URL(url, window.location.origin);
var changed = false;
trackingParams.forEach(function(p) {
if (u.searchParams.has(p)) {
u.searchParams.delete(p);
changed = true;
}
});
return changed ? u.toString() : url;
} catch (e) {
return url;
}
}
function cleanLinks() {
document.querySelectorAll('a[href]').forEach(function(a) {
var clean = cleanUrl(a.href);
if (clean !== a.href) a.href = clean;
});
}
cleanLinks();
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (node.nodeType === 1) {
if (node.tagName === 'A') cleanLinks();
node.querySelectorAll('a[href]').forEach(function(a) {
var clean = cleanUrl(a.href);
if (clean !== a.href) a.href = clean;
});
}
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); }
})();
(function(){
try {
var __m = "youtube.com";
var __re = new RegExp('^' + "youtube\\.com" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Auto-enable theater mode on YouTube
(function() {
function tryTheater() {
var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]');
if (btn && !btn.classList.contains('activated')) {
btn.click();
}
}
// Try immediately
tryTheater();
// Try after navigation (SPA)
var lastUrl = location.href;
setInterval(function() {
if (location.href !== lastUrl) {
lastUrl = location.href;
setTimeout(tryTheater, 500);
}
}, 1000);
// Also try on player load
var observer = new MutationObserver(tryTheater);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); }
})();
(function(){
try {
var __m = "*";
var __re = new RegExp('^' + ".*" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Remove or un-stick sticky/fixed headers that block content
(function() {
function unstick() {
document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) {
if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {
el.style.position = 'static';
el.style.top = 'auto';
el.style.zIndex = 'auto';
}
});
}
unstick();
var observer = new MutationObserver(unstick);
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });
})();
}
} catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); }
})();
})();
introduce operating system version ranges as part of the target; self-host native dynamic linker detection and native glibc version detection by andrewrk · Pull Request #4550 · ziglang/zig · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
introduce std.zig.CrossTarget which is distinct from std.Target. std.zig.CrossTarget wraps std.Target so that it can be annotated as "the native target" or an explicitly specified target.
std.Target.Os is moved to std.Target.Os.Tag. The former is now a struct which has the tag as well as version range information.
std.elf gains some more ELF header constants.
std.Target.parse gains the ability to parse operating system version ranges as well as glibc version.
Added std.Target.isGnuLibC().
self-hosted dynamic linker detection and glibc version detection. This also adds the improved logic using /usr/bin/env rather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: zig fails to detect musl as the native C ABI on alpine linux #2084
Note: this /usr/bin/env code is work-in-progress.
-target-glibc CLI option is removed in favor of the new -target syntax. Example: -target x86_64-linux-gnu.2.27
comptime code will have access to exactly which version(s) of an OS are being targeted.
Updated syntax for -target to take into account OS version ranges:
# still valid. default version range
-target x86_64-windows-msvc
# minimum windows version: XP
# maximum windows version: 10
-target x86_64-windows.xp...win10-msvc
# minimum windows version: 7
# maximum windows version: latest
-target x86_64-windows.win7-msvc
# linux example
-target aarch64-linux.3.16...5.3.1-musl
# specifying glibc version
-target mipsel-linux.4.10-gnu.2.1
Here's what it will look like to populate a std.Target:
complete the fallback /usr/bin/env ELF implementation
remove stage1 code for dynamic linker detection and glibc version detection
improve the std.Target.zigTriple function to render os version info
update zig build
update codebase to the new std.Target API
remove -mmacos_version_min and related features since it can now be automatically handled by the target OS version range feature
implement operating system version detection, which sets the min and max both to that value done for linux; others will become contributor friendly issues.
support -target native-native-gnu and -mcpu=native.
move -mcpu to be part of the target triple will open separate proposal for this
improve Builder.standardTargetOptions API and allow specifying a different default target, so that e.g. native-native-gnu could be the default for a given project on windows (as chosen by build.zig).
andrewrk
changed the title
introduce operating system version ranges as part of the targetintroduce operating system version ranges as part of the target; self-host native dynamic linker detection and native glibc version detectionFeb 25, 2020
In this branch Zig supports a more fine-grained sense of what is native and what is
not. Some examples:
# This is now allowed:
-target native
# Different OS but native CPU, default Windows C ABI:
-target native-windows
# This could be useful for example when running in Wine.
# Different CPU but native OS, native C ABI.
-target x86_64-native -mcpu=skylake
# Different C ABI but otherwise native target:
-target native-native-musl
-target native-native-gnu
# Different glibc version but otherwise native target:
-target native-native-gnu.2.25
# Different OS minimum version, but otherwise native target:
-target native-native.xp
Lots of breaking changes to related std lib APIs.
Calls to getOs() will need to be changed to getOsTag().
Calls to getArch() will need to be changed to getCpuArch().
Usage of Target.Cross and Target.Native need to be updated to use
CrossTarget API.
std.build.Builder.standardTargetOptions is changed to accept its
parameters as a struct with default values. It now has the ability to
specify a whitelist of targets allowed, as well as the default target.
Rather than two different ways of collecting the target, it's now always
a string that is validated, and prints helpful diagnostics for invalid
targets. This feature should now be actually useful, and contributions
welcome to further improve the user experience.
std.build.LibExeObjStep.setTheTarget is removed. std.build.LibExeObjStep.setTarget is updated to take a CrossTarget
parameter.
std.build.LibExeObjStep.setTargetGLibC is removed. glibc versions are
handled in the CrossTarget API and can be specified with the -target
triple.
* re-introduce `std.build.Target` which is distinct from `std.Target`.
`std.build.Target` wraps `std.Target` so that it can be annotated as
"the native target" or an explicitly specified target.
* `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
struct which has the tag as well as version range information.
* `std.elf` gains some more ELF header constants.
* `std.Target.parse` gains the ability to parse operating system
version ranges as well as glibc version.
* Added `std.Target.isGnuLibC()`.
* self-hosted dynamic linker detection and glibc version detection.
This also adds the improved logic using `/usr/bin/env` rather than
invoking the system C compiler to find the dynamic linker when zig
is statically linked. Related: #2084
Note: this `/usr/bin/env` code is work-in-progress.
* `-target-glibc` CLI option is removed in favor of the new `-target`
syntax. Example: `-target x86_64-linux-gnu.2.27`
closes#1907
Zig now supports a more fine-grained sense of what is native and what is
not. Some examples:
This is now allowed:
-target native
Different OS but native CPU, default Windows C ABI:
-target native-windows
This could be useful for example when running in Wine.
Different CPU but native OS, native C ABI.
-target x86_64-native -mcpu=skylake
Different C ABI but otherwise native target:
-target native-native-musl
-target native-native-gnu
Lots of breaking changes to related std lib APIs.
Calls to getOs() will need to be changed to getOsTag().
Calls to getArch() will need to be changed to getCpuArch().
Usage of Target.Cross and Target.Native need to be updated to use
CrossTarget API.
`std.build.Builder.standardTargetOptions` is changed to accept its
parameters as a struct with default values. It now has the ability to
specify a whitelist of targets allowed, as well as the default target.
Rather than two different ways of collecting the target, it's now always
a string that is validated, and prints helpful diagnostics for invalid
targets. This feature should now be actually useful, and contributions
welcome to further improve the user experience.
`std.build.LibExeObjStep.setTheTarget` is removed.
`std.build.LibExeObjStep.setTarget` is updated to take a CrossTarget
parameter.
`std.build.LibExeObjStep.setTargetGLibC` is removed. glibc versions are
handled in the CrossTarget API and can be specified with the `-target`
triple.
`std.builtin.Version` gains a `format` method.
* `std.Target.getStandardDynamicLinkerPath` =>
`std.Target.standardDynamicLinkerPath`
* it now takes a pointer to fixed size array rather than an allocator
* `std.zig.system.NativeTargetInfo.detect` now supports reading
PT_INTERP from /usr/bin/env
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Details
std.zig.CrossTargetwhich is distinct fromstd.Target.std.zig.CrossTargetwrapsstd.Targetso that it can be annotated as "the native target" or an explicitly specified target.std.Target.Osis moved tostd.Target.Os.Tag. The former is now a struct which has the tag as well as version range information.std.elfgains some more ELF header constants.std.Target.parsegains the ability to parse operating system version ranges as well as glibc version.std.Target.isGnuLibC()./usr/bin/envrather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: zig fails to detect musl as the native C ABI on alpine linux #2084Note: this
/usr/bin/envcode is work-in-progress.-target-glibcCLI option is removed in favor of the new-targetsyntax. Example:-target x86_64-linux-gnu.2.27closes#1907
What this means for Zig programmers
comptimecode will have access to exactly which version(s) of an OS are being targeted.Updated syntax for
-targetto take into account OS version ranges:Here's what it will look like to populate a
std.Target:Code that used
Target.parseneed not be updated.Checking for the OS when doing conditional compilation:
Option 1: easy, might get deprecated in the future:
Option 2, more verbose, less likely to be deprecated in the future:
Checklist:
/usr/bin/envELF implementation-mmacos_version_minand related features since it can now be automatically handled by the target OS version range featureimplement operating system version detection, which sets the min and max both to that valuedone for linux; others will become contributor friendly issues.-target native-native-gnuand-mcpu=native.movewill open separate proposal for this-mcputo be part of the target tripleBuilder.standardTargetOptionsAPI and allow specifying a different default target, so that e.g.native-native-gnucould be the default for a given project on windows (as chosen by build.zig).std.zig.CrossTarget.toTargetandstd.zig.system.NativeTargetInfo.detect.Follow-up Items